| Index: chrome/android/javatests/src/org/chromium/chrome/browser/OSKOverscrollTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/OSKOverscrollTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/OSKOverscrollTest.java
|
| index a5f0706b07fd4655ba8f315292b5133d9e49a292..2e157e6b46f8eaa8bc42ce491ed3f3184f198166 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/OSKOverscrollTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/OSKOverscrollTest.java
|
| @@ -8,11 +8,17 @@ import android.graphics.Rect;
|
| import android.support.test.filters.MediumTest;
|
| import android.test.MoreAsserts;
|
|
|
| +import org.junit.Assert;
|
| +import org.junit.Rule;
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
| +
|
| import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.test.util.CommandLineFlags;
|
| import org.chromium.base.test.util.RetryOnFailure;
|
| import org.chromium.base.test.util.UrlUtils;
|
| -import org.chromium.chrome.test.ChromeActivityTestCaseBase;
|
| +import org.chromium.chrome.test.ChromeActivityTestRule;
|
| +import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
| import org.chromium.content.browser.ContentViewCore;
|
| import org.chromium.content.browser.test.util.Criteria;
|
| import org.chromium.content.browser.test.util.CriteriaHelper;
|
| @@ -31,7 +37,14 @@ import java.util.concurrent.atomic.AtomicReference;
|
| * Integration test to ensure that OSK resizes only the visual viewport.
|
| */
|
|
|
| -public class OSKOverscrollTest extends ChromeActivityTestCaseBase<ChromeActivity> {
|
| +@RunWith(ChromeJUnit4ClassRunner.class)
|
| +@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
|
| + ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
|
| +public class OSKOverscrollTest {
|
| + @Rule
|
| + public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
|
| + new ChromeActivityTestRule<>(ChromeActivity.class);
|
| +
|
| private static final String FIXED_FOOTER_PAGE = UrlUtils.encodeHtmlDataUri(""
|
| + "<html>"
|
| + "<head>"
|
| @@ -65,23 +78,15 @@ public class OSKOverscrollTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| // point. Need some buffer for error.
|
| private static final int ERROR_EPS_PIX = 1;
|
|
|
| - public OSKOverscrollTest() {
|
| - super(ChromeActivity.class);
|
| - }
|
| -
|
| - @Override
|
| - public void startMainActivity() {
|
| - // Don't launch activity automatically.
|
| - }
|
| -
|
| private void waitForKeyboard() {
|
| // Wait until the keyboard is showing.
|
| CriteriaHelper.pollUiThread(new Criteria("Keyboard was never shown.") {
|
| @Override
|
| public boolean isSatisfied() {
|
| - return UiUtils.isKeyboardShowing(
|
| - getActivity(),
|
| - getActivity().getCurrentContentViewCore().getContainerView());
|
| + return UiUtils.isKeyboardShowing(mActivityTestRule.getActivity(),
|
| + mActivityTestRule.getActivity()
|
| + .getCurrentContentViewCore()
|
| + .getContainerView());
|
| }
|
| });
|
| }
|
| @@ -93,7 +98,7 @@ public class OSKOverscrollTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| MoreAsserts.assertNotEqual(jsonText.trim().toLowerCase(Locale.US), "null");
|
| return Integer.parseInt(jsonText);
|
| } catch (Exception ex) {
|
| - fail(ex.toString());
|
| + Assert.fail(ex.toString());
|
| }
|
| return -1;
|
| }
|
| @@ -109,19 +114,20 @@ public class OSKOverscrollTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| * @throws TimeoutException
|
| * @throws ExecutionException
|
| */
|
| + @Test
|
| @MediumTest
|
| @CommandLineFlags.Add({ChromeSwitches.ENABLE_OSK_OVERSCROLL})
|
| @RetryOnFailure
|
| public void testOnlyVisualViewportResizes()
|
| throws InterruptedException, TimeoutException, ExecutionException {
|
| - startMainActivityWithURL(FIXED_FOOTER_PAGE);
|
| + mActivityTestRule.startMainActivityWithURL(FIXED_FOOTER_PAGE);
|
|
|
| final AtomicReference<ContentViewCore> viewCoreRef = new AtomicReference<ContentViewCore>();
|
| final AtomicReference<WebContents> webContentsRef = new AtomicReference<WebContents>();
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| - viewCoreRef.set(getActivity().getCurrentContentViewCore());
|
| + viewCoreRef.set(mActivityTestRule.getActivity().getCurrentContentViewCore());
|
| webContentsRef.set(viewCoreRef.get().getWebContents());
|
| }
|
| });
|
| @@ -143,7 +149,7 @@ public class OSKOverscrollTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| // Get the position of the footer after bringing up the OSK. This should be the same as the
|
| // position before because only the visual viewport should have resized.
|
| Rect footerPositionAfter = DOMUtils.getNodeBounds(webContentsRef.get(), "footer");
|
| - assertEquals(footerPositionBefore, footerPositionAfter);
|
| + Assert.assertEquals(footerPositionBefore, footerPositionAfter);
|
|
|
| CriteriaHelper.pollInstrumentationThread(new Criteria() {
|
| @Override
|
| @@ -151,7 +157,9 @@ public class OSKOverscrollTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| // Verify that the size of the viewport before the OSK show is equal to the size of
|
| // the viewport after the OSK show plus the size of the keyboard.
|
| int viewportHeightAfterCss = getViewportHeight(webContentsRef.get());
|
| - int keyboardHeight = getActivity().getActivityTab().getSystemWindowInsetBottom();
|
| + int keyboardHeight = mActivityTestRule.getActivity()
|
| + .getActivityTab()
|
| + .getSystemWindowInsetBottom();
|
|
|
| int priorHeight = (int) (viewportHeightBeforeCss * cssToDevicePixFactor);
|
| int afterHeightPlusKeyboard =
|
|
|