ItemInflaterTest.java revision 5bf291fde3dfd64f264d525534730514a279c8fc
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.ItemInflater; 25 26public class ItemInflaterTest extends InstrumentationTestCase { 27 28 @SmallTest 29 public void testDefaultPackage() { 30 ItemInflater inflater = new ItemInflater(getInstrumentation().getContext()); 31 assertEquals("Default package should be the one containing Item class", 32 "com.android.setupwizardlib.items.", inflater.getDefaultPackage()); 33 } 34 35 @SmallTest 36 public void testInflate() { 37 ItemInflater inflater = new ItemInflater(getInstrumentation().getContext()); 38 Item item = inflater.inflate(R.xml.test_items); 39 assertTrue("Inflated item should be ItemGroup", item instanceof ItemGroup); 40 ItemGroup itemGroup = (ItemGroup) item; 41 Item[] children = itemGroup.getChildren(); 42 assertEquals("Title of first child should be Title1", "Title1", children[0].getTitle()); 43 assertEquals("ID of second child should be test_item_2", R.id.test_item_2, 44 children[1].getId()); 45 assertEquals("Summary of second child should be Summary2", "Summary2", 46 children[1].getSummary()); 47 } 48} 49