15bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam/* 25bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * Copyright (C) 2015 The Android Open Source Project 35bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * 45bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * Licensed under the Apache License, Version 2.0 (the "License"); 55bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * you may not use this file except in compliance with the License. 65bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * You may obtain a copy of the License at 75bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * 85bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * http://www.apache.org/licenses/LICENSE-2.0 95bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * 105bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * Unless required by applicable law or agreed to in writing, software 115bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * distributed under the License is distributed on an "AS IS" BASIS, 125bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * See the License for the specific language governing permissions and 145bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam * limitations under the License. 155bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam */ 165bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam 175bf291fde3dfd64f264d525534730514a279c8fcMaurice Lampackage com.android.setupwizardlib.test; 185bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam 195bf291fde3dfd64f264d525534730514a279c8fcMaurice Lamimport android.test.InstrumentationTestCase; 205bf291fde3dfd64f264d525534730514a279c8fcMaurice Lamimport android.test.suitebuilder.annotation.SmallTest; 215bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam 225bf291fde3dfd64f264d525534730514a279c8fcMaurice Lamimport com.android.setupwizardlib.items.Item; 235bf291fde3dfd64f264d525534730514a279c8fcMaurice Lamimport com.android.setupwizardlib.items.ItemGroup; 24960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lamimport com.android.setupwizardlib.items.ItemHierarchy; 255bf291fde3dfd64f264d525534730514a279c8fcMaurice Lamimport com.android.setupwizardlib.items.ItemInflater; 265bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam 275bf291fde3dfd64f264d525534730514a279c8fcMaurice Lampublic class ItemInflaterTest extends InstrumentationTestCase { 285bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam 295bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam @SmallTest 305bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam public void testDefaultPackage() { 315bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam ItemInflater inflater = new ItemInflater(getInstrumentation().getContext()); 325bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam assertEquals("Default package should be the one containing Item class", 335bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam "com.android.setupwizardlib.items.", inflater.getDefaultPackage()); 345bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam } 355bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam 365bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam @SmallTest 375bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam public void testInflate() { 385bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam ItemInflater inflater = new ItemInflater(getInstrumentation().getContext()); 39960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam ItemHierarchy item = inflater.inflate(R.xml.test_items); 405bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam assertTrue("Inflated item should be ItemGroup", item instanceof ItemGroup); 415bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam ItemGroup itemGroup = (ItemGroup) item; 42960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam 43960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam Item child0 = (Item) itemGroup.getItemAt(0); 44960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam Item child1 = (Item) itemGroup.getItemAt(1); 45960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam assertEquals("Title of first child should be Title1", "Title1", child0.getTitle()); 46960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam assertEquals("ID of second child should be test_item_2", R.id.test_item_2, child1.getId()); 475bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam assertEquals("Summary of second child should be Summary2", "Summary2", 48960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam child1.getSummary()); 495bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam } 505bf291fde3dfd64f264d525534730514a279c8fcMaurice Lam} 51