| Index: android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java
|
| diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java
|
| index 687e93c799090c9c59bda93a5f1e65ad7282692c..5d562d85f57e35940f951ce74ba7bbd0456d2311 100644
|
| --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java
|
| +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java
|
| @@ -36,9 +36,15 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
|
| private static final int secondContentWidth = 103;
|
| private static final int secondContentHeight = 397;
|
|
|
| + private static final int smallerContentSize = 25;
|
| + private static final int atMostMeasureSize = 50;
|
| + private static final int tooLargeContentSize = 100;
|
| +
|
| + private static final double initialPageScale = 1.0;
|
| +
|
| public void testCanQueryContentSize() {
|
| LayoutSizerDelegate delegate = new LayoutSizerDelegate();
|
| - AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate);
|
| + AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate, initialPageScale);
|
| final int contentWidth = 101;
|
| final int contentHeight = 389;
|
|
|
| @@ -53,7 +59,7 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
|
|
|
| public void testContentSizeChangeRequestsLayout() {
|
| LayoutSizerDelegate delegate = new LayoutSizerDelegate();
|
| - AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate);
|
| + AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate, initialPageScale);
|
|
|
| layoutSizer.onContentSizeChanged(firstContentWidth, firstContentHeight);
|
| final int requestLayoutCallCount = delegate.requestLayoutCallCount;
|
| @@ -64,7 +70,7 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
|
|
|
| public void testContentSizeChangeDoesNotRequestLayoutIfMeasuredExcatly() {
|
| LayoutSizerDelegate delegate = new LayoutSizerDelegate();
|
| - AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate);
|
| + AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate, initialPageScale);
|
|
|
| layoutSizer.onContentSizeChanged(firstContentWidth, firstContentHeight);
|
| layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(50, MeasureSpec.EXACTLY),
|
| @@ -75,13 +81,22 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
|
| assertEquals(requestLayoutCallCount, delegate.requestLayoutCallCount);
|
| }
|
|
|
| - public void testContentHeightGrowsTillAtMostSize() {
|
| + public void testDuplicateContentSizeChangeDoesNotRequestLayout() {
|
| LayoutSizerDelegate delegate = new LayoutSizerDelegate();
|
| - AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate);
|
| + AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate, initialPageScale);
|
| +
|
| + layoutSizer.onContentSizeChanged(firstContentWidth, firstContentHeight);
|
| + layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(50, MeasureSpec.EXACTLY),
|
| + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
| + final int requestLayoutCallCount = delegate.requestLayoutCallCount;
|
| + layoutSizer.onContentSizeChanged(firstContentWidth, firstContentHeight);
|
| +
|
| + assertEquals(requestLayoutCallCount, delegate.requestLayoutCallCount);
|
| + }
|
|
|
| - final int smallerContentSize = 25;
|
| - final int atMostMeasureSize = 50;
|
| - final int tooLargeContentSize = 100;
|
| + public void testContentHeightGrowsTillAtMostSize() {
|
| + LayoutSizerDelegate delegate = new LayoutSizerDelegate();
|
| + AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate, initialPageScale);
|
|
|
| layoutSizer.onContentSizeChanged(smallerContentSize, smallerContentSize);
|
| layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(atMostMeasureSize, MeasureSpec.AT_MOST),
|
| @@ -95,4 +110,49 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
|
| assertEquals(atMostMeasureSize, delegate.measuredWidth & View.MEASURED_SIZE_MASK);
|
| assertEquals(atMostMeasureSize, delegate.measuredHeight & View.MEASURED_SIZE_MASK);
|
| }
|
| +
|
| + public void testScaleChangeRequestsLayout() {
|
| + LayoutSizerDelegate delegate = new LayoutSizerDelegate();
|
| + AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate, initialPageScale);
|
| +
|
| + layoutSizer.onContentSizeChanged(firstContentWidth, firstContentHeight);
|
| + layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(atMostMeasureSize, MeasureSpec.EXACTLY),
|
| + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
| + final int requestLayoutCallCount = delegate.requestLayoutCallCount;
|
| + layoutSizer.onPageScaleChanged(initialPageScale + 0.5);
|
| +
|
| + assertEquals(requestLayoutCallCount + 1, delegate.requestLayoutCallCount);
|
| + }
|
| +
|
| + public void testDuplicateScaleChangeDoesNotRequestLayout() {
|
| + LayoutSizerDelegate delegate = new LayoutSizerDelegate();
|
| + AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate, initialPageScale);
|
| +
|
| + layoutSizer.onContentSizeChanged(firstContentWidth, firstContentHeight);
|
| + layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(50, MeasureSpec.EXACTLY),
|
| + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
| + final int requestLayoutCallCount = delegate.requestLayoutCallCount;
|
| + layoutSizer.onPageScaleChanged(initialPageScale);
|
| +
|
| + assertEquals(requestLayoutCallCount, delegate.requestLayoutCallCount);
|
| + }
|
| +
|
| + public void testScaleChangeGrowsTillAtMostSize() {
|
| + LayoutSizerDelegate delegate = new LayoutSizerDelegate();
|
| + AwLayoutSizer layoutSizer = new AwLayoutSizer(delegate, initialPageScale);
|
| +
|
| + final double tooLargePageScale = 3.00;
|
| +
|
| + layoutSizer.onContentSizeChanged(smallerContentSize, smallerContentSize);
|
| + layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(atMostMeasureSize, MeasureSpec.AT_MOST),
|
| + MeasureSpec.makeMeasureSpec(atMostMeasureSize, MeasureSpec.AT_MOST));
|
| + assertEquals(atMostMeasureSize, delegate.measuredWidth);
|
| + assertEquals(smallerContentSize, delegate.measuredHeight);
|
| +
|
| + layoutSizer.onPageScaleChanged(tooLargePageScale);
|
| + layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(atMostMeasureSize, MeasureSpec.AT_MOST),
|
| + MeasureSpec.makeMeasureSpec(atMostMeasureSize, MeasureSpec.AT_MOST));
|
| + assertEquals(atMostMeasureSize, delegate.measuredWidth & View.MEASURED_SIZE_MASK);
|
| + assertEquals(atMostMeasureSize, delegate.measuredHeight & View.MEASURED_SIZE_MASK);
|
| + }
|
| }
|
|
|