blob: e4905597d16ae2aede3b7f8bbe9560baac5c85fb [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
Neal Nguyen1d3165f2010-01-12 13:26:10 -080017package android.view;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080018
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080019import android.test.ActivityInstrumentationTestCase;
Tadashi G. Takaokab4470f22019-01-15 18:29:15 +090020
21import androidx.test.filters.MediumTest;
22
23import com.android.frameworks.coretests.R;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024
25public class IncludeTest extends ActivityInstrumentationTestCase<Include> {
26 public IncludeTest() {
Neal Nguyen1d3165f2010-01-12 13:26:10 -080027 super("com.android.frameworks.coretests", Include.class);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028 }
29
30 @Override
31 public void setUp() throws Exception {
32 super.setUp();
33 }
34
35 @MediumTest
36 public void testIncluded() throws Exception {
37 final Include activity = getActivity();
38
39 final View button1 = activity.findViewById(R.id.included_button);
40 assertNotNull("The layout include_button was not included", button1);
41
42 final View button2 = activity.findViewById(R.id.included_button_overriden);
43 assertNotNull("The layout include_button was not included with overriden id", button2);
44 }
45
46 @MediumTest
47 public void testIncludedWithLayoutParams() throws Exception {
48 final Include activity = getActivity();
49
50 final View button1 = activity.findViewById(R.id.included_button);
51 final View button2 = activity.findViewById(R.id.included_button_overriden);
52
53 assertTrue("Both buttons should have different width",
54 button1.getLayoutParams().width != button2.getLayoutParams().width);
55 assertTrue("Both buttons should have different height",
56 button1.getLayoutParams().height != button2.getLayoutParams().height);
57 }
58
59 @MediumTest
60 public void testIncludedWithVisibility() throws Exception {
61 final Include activity = getActivity();
62 final View button1 = activity.findViewById(R.id.included_button_visibility);
63
64 assertEquals("Included button should be invisible", View.INVISIBLE, button1.getVisibility());
65 }
66
Brett Chabot5535bbd2009-10-26 17:44:38 -070067 // TODO: needs to be adjusted to pass on non-HVGA displays
68 // @MediumTest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 public void testIncludedWithSize() throws Exception {
70 final Include activity = getActivity();
71 final View button1 = activity.findViewById(R.id.included_button_with_size);
72
73 final ViewGroup.LayoutParams lp = button1.getLayoutParams();
74 assertEquals("Included button should be 23dip x 23dip", 23, lp.width);
75 assertEquals("Included button should be 23dip x 23dip", 23, lp.height);
76 }
77}