Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.chrome.browser; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.graphics.Rect; | 7 import android.graphics.Rect; |
| 8 import android.support.test.filters.MediumTest; | 8 import android.support.test.filters.MediumTest; |
| 9 import android.test.MoreAsserts; | 9 import android.test.MoreAsserts; |
| 10 import android.widget.FrameLayout; | |
| 10 | 11 |
| 11 import org.chromium.base.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
| 12 import org.chromium.base.test.util.CommandLineFlags; | 13 import org.chromium.base.test.util.CommandLineFlags; |
| 13 import org.chromium.base.test.util.RetryOnFailure; | 14 import org.chromium.base.test.util.RetryOnFailure; |
| 14 import org.chromium.base.test.util.UrlUtils; | 15 import org.chromium.base.test.util.UrlUtils; |
| 16 import org.chromium.chrome.browser.tab.TabViewAndroidDelegate; | |
| 15 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 17 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 16 import org.chromium.content.browser.ContentViewCore; | 18 import org.chromium.content.browser.ContentViewCore; |
| 17 import org.chromium.content.browser.test.util.Criteria; | 19 import org.chromium.content.browser.test.util.Criteria; |
| 18 import org.chromium.content.browser.test.util.CriteriaHelper; | 20 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 19 import org.chromium.content.browser.test.util.DOMUtils; | 21 import org.chromium.content.browser.test.util.DOMUtils; |
| 20 import org.chromium.content.browser.test.util.JavaScriptUtils; | 22 import org.chromium.content.browser.test.util.JavaScriptUtils; |
| 21 import org.chromium.content_public.browser.WebContents; | 23 import org.chromium.content_public.browser.WebContents; |
| 22 import org.chromium.ui.UiUtils; | 24 import org.chromium.ui.UiUtils; |
| 23 | 25 |
| 24 import java.util.Locale; | 26 import java.util.Locale; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 // position before because only the visual viewport should have resized. | 146 // position before because only the visual viewport should have resized. |
| 145 Rect footerPositionAfter = DOMUtils.getNodeBounds(webContentsRef.get(), "footer"); | 147 Rect footerPositionAfter = DOMUtils.getNodeBounds(webContentsRef.get(), "footer"); |
| 146 assertEquals(footerPositionBefore, footerPositionAfter); | 148 assertEquals(footerPositionBefore, footerPositionAfter); |
| 147 | 149 |
| 148 CriteriaHelper.pollInstrumentationThread(new Criteria() { | 150 CriteriaHelper.pollInstrumentationThread(new Criteria() { |
| 149 @Override | 151 @Override |
| 150 public boolean isSatisfied() { | 152 public boolean isSatisfied() { |
| 151 // Verify that the size of the viewport before the OSK show is e qual to the size of | 153 // Verify that the size of the viewport before the OSK show is e qual to the size of |
| 152 // the viewport after the OSK show plus the size of the keyboard . | 154 // the viewport after the OSK show plus the size of the keyboard . |
| 153 int viewportHeightAfterCss = getViewportHeight(webContentsRef.ge t()); | 155 int viewportHeightAfterCss = getViewportHeight(webContentsRef.ge t()); |
| 154 int keyboardHeight = | 156 TabViewAndroidDelegate tvad = new TabViewAndroidDelegate( |
|
Ted C
2017/04/06 19:07:55
this doesn't seem to be in the spirit of the test.
Jinsuk Kim
2017/04/06 22:08:46
Point taken. In fact this test defeats the goal of
| |
| 155 viewCoreRef.get().getContentViewClient().getSystemWindow InsetBottom(); | 157 getActivity().getActivityTab(), new FrameLayout(getActiv ity())); |
| 158 int keyboardHeight = tvad.getSystemWindowInsetBottom(); | |
| 156 | 159 |
| 157 int priorHeight = (int) (viewportHeightBeforeCss * cssToDevicePi xFactor); | 160 int priorHeight = (int) (viewportHeightBeforeCss * cssToDevicePi xFactor); |
| 158 int afterHeightPlusKeyboard = | 161 int afterHeightPlusKeyboard = |
| 159 (int) (viewportHeightAfterCss * cssToDevicePixFactor) + keyboardHeight; | 162 (int) (viewportHeightAfterCss * cssToDevicePixFactor) + keyboardHeight; |
| 160 updateFailureReason("Values [" + priorHeight + "], [" + afterHei ghtPlusKeyboard | 163 updateFailureReason("Values [" + priorHeight + "], [" + afterHei ghtPlusKeyboard |
| 161 + "] did not match within allowed error range [" + ERROR _EPS_PIX + "]"); | 164 + "] did not match within allowed error range [" + ERROR _EPS_PIX + "]"); |
| 162 return almostEqual(priorHeight, afterHeightPlusKeyboard); | 165 return almostEqual(priorHeight, afterHeightPlusKeyboard); |
| 163 } | 166 } |
| 164 }); | 167 }); |
| 165 } | 168 } |
| 166 } | 169 } |
| OLD | NEW |