1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.setupwizardlib.test; 18 19import android.test.InstrumentationTestCase; 20import android.test.suitebuilder.annotation.SmallTest; 21 22import com.android.setupwizardlib.items.Item; 23import com.android.setupwizardlib.items.ItemGroup; 24import com.android.setupwizardlib.items.ItemHierarchy; 25import com.android.setupwizardlib.items.ItemInflater; 26 27public class ItemInflaterTest extends InstrumentationTestCase { 28 29 @SmallTest 30 public void testDefaultPackage() { 31 ItemInflater inflater = new ItemInflater(getInstrumentation().getContext()); 32 assertEquals("Default package should be the one containing Item class", 33 "com.android.setupwizardlib.items.", inflater.getDefaultPackage()); 34 } 35 36 @SmallTest 37 public void testInflate() { 38 ItemInflater inflater = new ItemInflater(getInstrumentation().getContext()); 39 ItemHierarchy item = inflater.inflate(R.xml.test_items); 40 assertTrue("Inflated item should be ItemGroup", item instanceof ItemGroup); 41 ItemGroup itemGroup = (ItemGroup) item; 42 43 Item child0 = (Item) itemGroup.getItemAt(0); 44 Item child1 = (Item) itemGroup.getItemAt(1); 45 assertEquals("Title of first child should be Title1", "Title1", child0.getTitle()); 46 assertEquals("ID of second child should be test_item_2", R.id.test_item_2, child1.getId()); 47 assertEquals("Summary of second child should be Summary2", "Summary2", 48 child1.getSummary()); 49 } 50} 51