diff options
author | Chris Wren <cwren@android.com> | 2012-04-24 09:50:03 -0400 |
---|---|---|
committer | Chris Wren <cwren@android.com> | 2012-04-24 16:14:31 -0400 |
commit | 54dfa5d90e49037eba05f5278076b45428b2bd11 (patch) | |
tree | fc4d22a42aae3315ee966bd04b492ac6cb752881 /core/tests | |
parent | 57a6e14e576f7f08001027cce67955e9820a726f (diff) | |
download | frameworks_base-54dfa5d90e49037eba05f5278076b45428b2bd11.zip frameworks_base-54dfa5d90e49037eba05f5278076b45428b2bd11.tar.gz frameworks_base-54dfa5d90e49037eba05f5278076b45428b2bd11.tar.bz2 |
Don't allow children of a SizeAdaptiveLayout to measure outside their declared range of valid sizes.
Bug: 6377749
Change-Id: Ie706006eee9c0ed8dda468212a652941b8e20be0
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/coretests/res/layout/size_adaptive_lies.xml | 40 | ||||
-rw-r--r-- | core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java | 34 |
2 files changed, 73 insertions, 1 deletions
diff --git a/core/tests/coretests/res/layout/size_adaptive_lies.xml b/core/tests/coretests/res/layout/size_adaptive_lies.xml new file mode 100644 index 0000000..7de892e --- /dev/null +++ b/core/tests/coretests/res/layout/size_adaptive_lies.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<com.android.internal.widget.SizeAdaptiveLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:internal="http://schemas.android.com/apk/prv/res/android" + android:id="@+id/multi1" + android:layout_width="match_parent" + android:layout_height="64dp" > + + <include + android:id="@+id/one_u" + layout="@layout/size_adaptive_one_u" + android:layout_width="fill_parent" + android:layout_height="64dp" + internal:layout_minHeight="64dp" + internal:layout_maxHeight="64dp" + /> + + <include + android:id="@+id/four_u" + layout="@layout/size_adaptive_one_u" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + internal:layout_minHeight="65dp" + internal:layout_maxHeight="unbounded"/> + +</com.android.internal.widget.SizeAdaptiveLayout> diff --git a/core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java b/core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java index a937f65..efd06bf 100644 --- a/core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java +++ b/core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java @@ -449,10 +449,42 @@ public class SizeAdaptiveLayoutTest extends AndroidTestCase { panel.getBackground() instanceof ColorDrawable); } + @SmallTest + public void testOpenSmallEvenWhenLargeIsActuallySmall() { + inflate(R.layout.size_adaptive_lies); + SizeAdaptiveLayout.LayoutParams lp = + (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams(); + int height = (int) lp.minHeight; + + measureAndLayout(height); + + assertEquals("1U should be visible", + View.VISIBLE, + mSmallView.getVisibility()); + assertTrue("1U should also have been measured", + mSmallView.getMeasuredHeight() > 0); + } + + @SmallTest + public void testOpenLargeEvenWhenLargeIsActuallySmall() { + inflate(R.layout.size_adaptive_lies); + SizeAdaptiveLayout.LayoutParams lp = + (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams(); + int height = (int) lp.minHeight; + + measureAndLayout(height); + + assertEquals("4U should be visible", + View.VISIBLE, + mLargeView.getVisibility()); + assertTrue("4U should also have been measured", + mLargeView.getMeasuredHeight() > 0); + } + private void measureAndLayout(int height) { // manually measure it, and lay it out int measureSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.AT_MOST); mSizeAdaptiveLayout.measure(500, measureSpec); - mSizeAdaptiveLayout.layout(0, 0, 500, height); + mSizeAdaptiveLayout.layout(0, 0, 500, mSizeAdaptiveLayout.getMeasuredHeight()); } } |