Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java

Issue 35403002: Set a fixed layout size only if the container view has a WRAP_CONTENT layout mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comments Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwLayoutSizer.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5d8b56bf48a088d342214572afa820caa9f8a4d9..357e9226393839c1b8af8c12bee381c494f27bed 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
@@ -20,6 +20,7 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
public int measuredHeight;
public int fixedLayoutWidth;
public int fixedLayoutHeight;
+ public boolean heightWrapContent;
@Override
public void requestLayout() {
@@ -38,6 +39,11 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
fixedLayoutWidth = widthDip;
fixedLayoutHeight = heightDip;
}
+
+ @Override
+ public boolean isLayoutParamsHeightWrapContent() {
+ return heightWrapContent;
+ }
}
private static final int FIRST_CONTENT_WIDTH = 101;
@@ -382,7 +388,7 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
@SmallTest
@Feature({"AndroidWebView"})
- public void testViewportWithWrapContentMeasureSpec() {
+ public void testViewportWithUnspecifiedMeasureSpec() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
layoutSizer.setDelegate(delegate);
@@ -391,7 +397,6 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
final int pageScale = 2;
final int dipAndPageScale = (int) (dipScale * pageScale);
-
int contentWidth = 800;
int contentHeight = 400;
int atMostWidth = contentWidth * dipAndPageScale;
@@ -431,6 +436,41 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
@SmallTest
@Feature({"AndroidWebView"})
+ public void testViewportWithAtMostMeasureSpec() {
+ AwLayoutSizer layoutSizer = new AwLayoutSizer();
+ LayoutSizerDelegate delegate = new LayoutSizerDelegate();
+ delegate.heightWrapContent = true;
+ layoutSizer.setDelegate(delegate);
+
+ final float dipScale = 1.5f;
+ final int pageScale = 2;
+ final int dipAndPageScale = (int) (dipScale * pageScale);
+
+ int contentWidth = 800;
+ int contentHeight = 400;
+ int contentWidthPix = contentWidth * dipAndPageScale;
+ int contentHeightPix = contentHeight * dipAndPageScale;
+
+ layoutSizer.setDIPScale(dipScale);
+ layoutSizer.onContentSizeChanged(contentWidth, contentHeight);
+ layoutSizer.onPageScaleChanged(pageScale);
+ layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(contentWidthPix, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(contentHeightPix * 2, MeasureSpec.AT_MOST));
+
+ assertTrue(delegate.setMeasuredDimensionCalled);
+ int measuredWidth = delegate.measuredWidth & View.MEASURED_SIZE_MASK;
+ int measuredHeight = delegate.measuredHeight & View.MEASURED_SIZE_MASK;
+
+ int sizeWidth = measuredWidth;
+ int sizeHeight = measuredHeight;
+ layoutSizer.onSizeChanged(sizeWidth, sizeHeight, 0, 0);
+
+ assertEquals(contentWidth, delegate.fixedLayoutWidth);
+ assertEquals(AwLayoutSizer.FIXED_LAYOUT_HEIGHT, delegate.fixedLayoutHeight);
+ }
+
+ @SmallTest
+ @Feature({"AndroidWebView"})
public void testFixedLayoutViewportGoesBackToZeroWithWrapContentMeasureSpec() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -465,6 +505,7 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
public void testFixedLayoutSizeUpdatedOnPageScaleChangeItNoLayoutRequest() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
+ delegate.heightWrapContent = true;
layoutSizer.setDelegate(delegate);
layoutSizer.setDIPScale(DIP_SCALE);
@@ -514,4 +555,24 @@ public class AwLayoutSizerTest extends InstrumentationTestCase {
assertEquals(fixedLayoutWidth * 2, delegate.fixedLayoutWidth);
}
+
+ @SmallTest
+ @Feature({"AndroidWebView"})
+ public void testFixedLayoutSizeDoesNotDependOnMeasureSpec() {
+ AwLayoutSizer layoutSizer = new AwLayoutSizer();
+ LayoutSizerDelegate delegate = new LayoutSizerDelegate();
+ delegate.heightWrapContent = false;
+ layoutSizer.setDelegate(delegate);
+ layoutSizer.setDIPScale(DIP_SCALE);
+
+ layoutSizer.onContentSizeChanged(TOO_LARGE_CONTENT_SIZE, TOO_LARGE_CONTENT_SIZE);
+ layoutSizer.onPageScaleChanged(INITIAL_PAGE_SCALE);
+ layoutSizer.onMeasure(
+ MeasureSpec.makeMeasureSpec(AT_MOST_MEASURE_SIZE, MeasureSpec.AT_MOST),
+ MeasureSpec.makeMeasureSpec(AT_MOST_MEASURE_SIZE, MeasureSpec.AT_MOST));
+ layoutSizer.onSizeChanged(AT_MOST_MEASURE_SIZE, AT_MOST_MEASURE_SIZE, 0, 0);
+
+ assertEquals(0, delegate.fixedLayoutWidth);
+ assertEquals(0, delegate.fixedLayoutHeight);
+ }
}
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwLayoutSizer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698