| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
| 6 | 6 |
| 7 import android.graphics.Color; | 7 import android.graphics.Color; |
| 8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
| 9 import android.view.View; | 9 import android.view.View; |
| 10 import android.view.ViewGroup.LayoutParams; | 10 import android.view.ViewGroup.LayoutParams; |
| 11 import android.widget.LinearLayout; | 11 import android.widget.LinearLayout; |
| 12 | 12 |
| 13 import org.chromium.android_webview.AwContents; | 13 import org.chromium.android_webview.AwContents; |
| 14 import org.chromium.android_webview.AwContentsClient; | 14 import org.chromium.android_webview.AwContentsClient; |
| 15 import org.chromium.android_webview.AwLayoutSizer; | 15 import org.chromium.android_webview.AwLayoutSizer; |
| 16 import org.chromium.android_webview.test.util.CommonResources; | 16 import org.chromium.android_webview.test.util.CommonResources; |
| 17 import org.chromium.android_webview.test.util.GraphicsTestUtils; | 17 import org.chromium.android_webview.test.util.GraphicsTestUtils; |
| 18 import org.chromium.base.test.util.Feature; | 18 import org.chromium.base.test.util.Feature; |
| 19 import org.chromium.base.test.util.parameter.ParameterizedTest; |
| 19 import org.chromium.content.browser.test.util.CallbackHelper; | 20 import org.chromium.content.browser.test.util.CallbackHelper; |
| 20 import org.chromium.ui.gfx.DeviceDisplayInfo; | 21 import org.chromium.ui.gfx.DeviceDisplayInfo; |
| 21 | 22 |
| 22 import java.util.concurrent.atomic.AtomicReference; | 23 import java.util.concurrent.atomic.AtomicReference; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Tests for certain edge cases related to integrating with the Android view sys
tem. | 26 * Tests for certain edge cases related to integrating with the Android view sys
tem. |
| 26 */ | 27 */ |
| 27 public class AndroidViewIntegrationTest extends AwTestBase { | 28 public class AndroidViewIntegrationTest extends AwTestBase { |
| 28 private static final int CONTENT_SIZE_CHANGE_STABILITY_TIMEOUT_MS = 1000; | 29 private static final int CONTENT_SIZE_CHANGE_STABILITY_TIMEOUT_MS = 1000; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 297 |
| 297 final int contentSizeChangeCallCount = mOnContentSizeChangedHelper.getCa
llCount(); | 298 final int contentSizeChangeCallCount = mOnContentSizeChangedHelper.getCa
llCount(); |
| 298 loadDataAsync(testContainerView.getAwContents(), htmlData, "text/html",
false); | 299 loadDataAsync(testContainerView.getAwContents(), htmlData, "text/html",
false); |
| 299 | 300 |
| 300 waitForContentSizeToChangeTo(mOnContentSizeChangedHelper, contentSizeCha
ngeCallCount, | 301 waitForContentSizeToChangeTo(mOnContentSizeChangedHelper, contentSizeCha
ngeCallCount, |
| 301 widthCss, heightCss); | 302 widthCss, heightCss); |
| 302 } | 303 } |
| 303 | 304 |
| 304 @SmallTest | 305 @SmallTest |
| 305 @Feature({"AndroidWebView"}) | 306 @Feature({"AndroidWebView"}) |
| 307 // Run in single-process mode only. Blocked by rendering support crbug.com/5
26842. |
| 308 @ParameterizedTest.Set |
| 306 public void testViewIsNotBlankInWrapContentsMode() throws Throwable { | 309 public void testViewIsNotBlankInWrapContentsMode() throws Throwable { |
| 307 final TestAwContentsClient contentsClient = new TestAwContentsClient(); | 310 final TestAwContentsClient contentsClient = new TestAwContentsClient(); |
| 308 final AwTestContainerView testContainerView = | 311 final AwTestContainerView testContainerView = |
| 309 createCustomTestContainerViewOnMainSync(contentsClient, View.VIS
IBLE); | 312 createCustomTestContainerViewOnMainSync(contentsClient, View.VIS
IBLE); |
| 310 assertZeroHeight(testContainerView); | 313 assertZeroHeight(testContainerView); |
| 311 | 314 |
| 312 final double deviceDIPScale = | 315 final double deviceDIPScale = |
| 313 DeviceDisplayInfo.create(testContainerView.getContext()).getDIPS
cale(); | 316 DeviceDisplayInfo.create(testContainerView.getContext()).getDIPS
cale(); |
| 314 | 317 |
| 315 final int contentWidthCss = 142; | 318 final int contentWidthCss = 142; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 mOnContentSizeChangedHelper.waitForCallback(contentSizeChangeCallCount); | 428 mOnContentSizeChangedHelper.waitForCallback(contentSizeChangeCallCount); |
| 426 | 429 |
| 427 // As a result of calling the onSizeChanged method the layout size shoul
d be updated to | 430 // As a result of calling the onSizeChanged method the layout size shoul
d be updated to |
| 428 // match the width of the webview and the text we previously loaded shou
ld reflow making the | 431 // match the width of the webview and the text we previously loaded shou
ld reflow making the |
| 429 // contents width match the WebView width. | 432 // contents width match the WebView width. |
| 430 assertEquals(expectedWidthCss, mOnContentSizeChangedHelper.getWidth()); | 433 assertEquals(expectedWidthCss, mOnContentSizeChangedHelper.getWidth()); |
| 431 assertTrue(mOnContentSizeChangedHelper.getHeight() < narrowLayoutHeight)
; | 434 assertTrue(mOnContentSizeChangedHelper.getHeight() < narrowLayoutHeight)
; |
| 432 assertTrue(mOnContentSizeChangedHelper.getHeight() > 0); | 435 assertTrue(mOnContentSizeChangedHelper.getHeight() > 0); |
| 433 } | 436 } |
| 434 } | 437 } |
| OLD | NEW |