2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 import android.view.Include;
20 import com.android.frameworks.coretests.R;
22 import android.test.ActivityInstrumentationTestCase;
23 import android.test.suitebuilder.annotation.MediumTest;
24 import android.view.View;
25 import android.view.ViewGroup;
27 public class IncludeTest extends ActivityInstrumentationTestCase<Include> {
28 public IncludeTest() {
29 super("com.android.frameworks.coretests", Include.class);
33 public void setUp() throws Exception {
38 public void testIncluded() throws Exception {
39 final Include activity = getActivity();
41 final View button1 = activity.findViewById(R.id.included_button);
42 assertNotNull("The layout include_button was not included", button1);
44 final View button2 = activity.findViewById(R.id.included_button_overriden);
45 assertNotNull("The layout include_button was not included with overriden id", button2);
49 public void testIncludedWithLayoutParams() throws Exception {
50 final Include activity = getActivity();
52 final View button1 = activity.findViewById(R.id.included_button);
53 final View button2 = activity.findViewById(R.id.included_button_overriden);
55 assertTrue("Both buttons should have different width",
56 button1.getLayoutParams().width != button2.getLayoutParams().width);
57 assertTrue("Both buttons should have different height",
58 button1.getLayoutParams().height != button2.getLayoutParams().height);
62 public void testIncludedWithVisibility() throws Exception {
63 final Include activity = getActivity();
64 final View button1 = activity.findViewById(R.id.included_button_visibility);
66 assertEquals("Included button should be invisible", View.INVISIBLE, button1.getVisibility());
69 // TODO: needs to be adjusted to pass on non-HVGA displays
71 public void testIncludedWithSize() throws Exception {
72 final Include activity = getActivity();
73 final View button1 = activity.findViewById(R.id.included_button_with_size);
75 final ViewGroup.LayoutParams lp = button1.getLayoutParams();
76 assertEquals("Included button should be 23dip x 23dip", 23, lp.width);
77 assertEquals("Included button should be 23dip x 23dip", 23, lp.height);