1/*
2 * Copyright (C) 2007 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 android.view;
18
19import android.view.Include;
20import com.android.frameworks.coretests.R;
21
22import android.test.ActivityInstrumentationTestCase;
23import android.test.suitebuilder.annotation.MediumTest;
24import android.view.View;
25import android.view.ViewGroup;
26
27public class IncludeTest extends ActivityInstrumentationTestCase<Include> {
28    public IncludeTest() {
29        super("com.android.frameworks.coretests", Include.class);
30    }
31
32    @Override
33    public void setUp() throws Exception {
34        super.setUp();
35    }
36
37    @MediumTest
38    public void testIncluded() throws Exception {
39        final Include activity = getActivity();
40
41        final View button1 = activity.findViewById(R.id.included_button);
42        assertNotNull("The layout include_button was not included", button1);
43
44        final View button2 = activity.findViewById(R.id.included_button_overriden);
45        assertNotNull("The layout include_button was not included with overriden id", button2);
46    }
47
48    @MediumTest
49    public void testIncludedWithLayoutParams() throws Exception {
50        final Include activity = getActivity();
51
52        final View button1 = activity.findViewById(R.id.included_button);
53        final View button2 = activity.findViewById(R.id.included_button_overriden);
54
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);
59    }
60
61    @MediumTest
62    public void testIncludedWithVisibility() throws Exception {
63        final Include activity = getActivity();
64        final View button1 = activity.findViewById(R.id.included_button_visibility);
65
66        assertEquals("Included button should be invisible", View.INVISIBLE, button1.getVisibility());
67    }
68
69    // TODO: needs to be adjusted to pass on non-HVGA displays
70    // @MediumTest
71    public void testIncludedWithSize() throws Exception {
72        final Include activity = getActivity();
73        final View button1 = activity.findViewById(R.id.included_button_with_size);
74
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);
78    }
79}
80