The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Neal Nguyen | 1d3165f | 2010-01-12 13:26:10 -0800 | [diff] [blame] | 17 | package android.view; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.test.ActivityInstrumentationTestCase; |
Tadashi G. Takaoka | b4470f2 | 2019-01-15 18:29:15 +0900 | [diff] [blame] | 20 | |
| 21 | import androidx.test.filters.MediumTest; |
| 22 | |
| 23 | import com.android.frameworks.coretests.R; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
| 25 | public class IncludeTest extends ActivityInstrumentationTestCase<Include> { |
| 26 | public IncludeTest() { |
Neal Nguyen | 1d3165f | 2010-01-12 13:26:10 -0800 | [diff] [blame] | 27 | super("com.android.frameworks.coretests", Include.class); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | } |
| 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 Chabot | 5535bbd | 2009-10-26 17:44:38 -0700 | [diff] [blame] | 67 | // TODO: needs to be adjusted to pass on non-HVGA displays |
| 68 | // @MediumTest |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | 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 | } |