| 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.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
| 8 import android.view.View; | 8 import android.view.View; |
| 9 import android.view.ViewGroup.LayoutParams; | 9 import android.view.ViewGroup.LayoutParams; |
| 10 import android.widget.LinearLayout; | 10 import android.widget.LinearLayout; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 assertZeroHeight(testContainerView); | 336 assertZeroHeight(testContainerView); |
| 337 | 337 |
| 338 final double deviceDIPScale = | 338 final double deviceDIPScale = |
| 339 DeviceDisplayInfo.create(testContainerView.getContext()).getDIPScale
(); | 339 DeviceDisplayInfo.create(testContainerView.getContext()).getDIPScale
(); |
| 340 | 340 |
| 341 final int contentWidthCss = 142; | 341 final int contentWidthCss = 142; |
| 342 final int contentHeightCss = 180; | 342 final int contentHeightCss = 180; |
| 343 | 343 |
| 344 final int expectedWidthCss = | 344 final int expectedWidthCss = |
| 345 (int) Math.ceil(getRootLayoutWidthOnMainThread() / deviceDIPScale); | 345 (int) Math.ceil(getRootLayoutWidthOnMainThread() / deviceDIPScale); |
| 346 final int expectedHeightCss = contentHeightCss + | 346 final int expectedHeightCss = contentHeightCss; |
| 347 // The second div in the contents is styled to have 150% of the view
port height, hence | |
| 348 // the 1.5. | |
| 349 (int) (AwLayoutSizer.FIXED_LAYOUT_HEIGHT * 1.5); | |
| 350 | 347 |
| 351 loadPageOfSizeAndWaitForSizeChange(testContainerView.getAwContents(), | 348 loadPageOfSizeAndWaitForSizeChange(testContainerView.getAwContents(), |
| 352 mOnContentSizeChangedHelper, expectedWidthCss, contentHeightCss,
true); | 349 mOnContentSizeChangedHelper, expectedWidthCss, contentHeightCss,
true); |
| 353 | 350 |
| 354 waitForNoLayoutsPending(); | 351 waitForNoLayoutsPending(); |
| 355 assertEquals(expectedWidthCss, mOnContentSizeChangedHelper.getWidth()); | 352 assertEquals(expectedWidthCss, mOnContentSizeChangedHelper.getWidth()); |
| 356 assertEquals(expectedHeightCss, mOnContentSizeChangedHelper.getHeight())
; | 353 assertEquals(expectedHeightCss, mOnContentSizeChangedHelper.getHeight())
; |
| 357 } | 354 } |
| 358 | 355 |
| 359 @SmallTest | 356 @SmallTest |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 mOnContentSizeChangedHelper.waitForCallback(contentSizeChangeCallCount); | 396 mOnContentSizeChangedHelper.waitForCallback(contentSizeChangeCallCount); |
| 400 | 397 |
| 401 // As a result of calling the onSizeChanged method the layout size shoul
d be updated to | 398 // As a result of calling the onSizeChanged method the layout size shoul
d be updated to |
| 402 // match the width of the webview and the text we previously loaded shou
ld reflow making the | 399 // match the width of the webview and the text we previously loaded shou
ld reflow making the |
| 403 // contents width match the WebView width. | 400 // contents width match the WebView width. |
| 404 assertEquals(expectedWidthCss, mOnContentSizeChangedHelper.getWidth()); | 401 assertEquals(expectedWidthCss, mOnContentSizeChangedHelper.getWidth()); |
| 405 assertTrue(mOnContentSizeChangedHelper.getHeight() < narrowLayoutHeight)
; | 402 assertTrue(mOnContentSizeChangedHelper.getHeight() < narrowLayoutHeight)
; |
| 406 assertTrue(mOnContentSizeChangedHelper.getHeight() > 0); | 403 assertTrue(mOnContentSizeChangedHelper.getHeight() > 0); |
| 407 } | 404 } |
| 408 } | 405 } |
| OLD | NEW |