Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.content_shell_apk; | 5 package org.chromium.content_shell_apk; |
| 6 | 6 |
| 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; | 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
| 8 | 8 |
| 9 import android.annotation.TargetApi; | 9 import android.annotation.TargetApi; |
| 10 import android.app.Activity; | 10 import android.app.Activity; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 import org.chromium.base.test.util.UrlUtils; | 25 import org.chromium.base.test.util.UrlUtils; |
| 26 import org.chromium.content.browser.ContentView; | 26 import org.chromium.content.browser.ContentView; |
| 27 import org.chromium.content.browser.ContentViewCore; | 27 import org.chromium.content.browser.ContentViewCore; |
| 28 import org.chromium.content.browser.test.util.Criteria; | 28 import org.chromium.content.browser.test.util.Criteria; |
| 29 import org.chromium.content.browser.test.util.CriteriaHelper; | 29 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 30 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; | 30 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
| 31 import org.chromium.content_public.browser.LoadUrlParams; | 31 import org.chromium.content_public.browser.LoadUrlParams; |
| 32 import org.chromium.content_public.browser.NavigationController; | 32 import org.chromium.content_public.browser.NavigationController; |
| 33 import org.chromium.content_public.browser.WebContents; | 33 import org.chromium.content_public.browser.WebContents; |
| 34 import org.chromium.content_shell.Shell; | 34 import org.chromium.content_shell.Shell; |
| 35 import org.chromium.content_shell.ShellViewAndroidDelegate.OnCursorUpdateHelper; | |
| 35 | 36 |
| 36 import java.util.concurrent.Callable; | 37 import java.util.concurrent.Callable; |
| 37 import java.util.concurrent.ExecutionException; | 38 import java.util.concurrent.ExecutionException; |
| 38 import java.util.concurrent.TimeUnit; | 39 import java.util.concurrent.TimeUnit; |
| 39 | 40 |
| 40 /** | 41 /** |
| 41 * Implementation of utility methods for ContentShellTestBase and ContentShellAc tivityTestRule to | 42 * Implementation of utility methods for ContentShellTestBase and ContentShellAc tivityTestRule to |
| 42 * wrap around during instrumentation test JUnit3 to JUnit4 migration | 43 * wrap around during instrumentation test JUnit3 to JUnit4 migration |
| 43 * | 44 * |
| 44 * Please do not use this class' methods in places other than {@link ContentShel lTestBase} | 45 * Please do not use this class' methods in places other than {@link ContentShel lTestBase} |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 } | 110 } |
| 110 if (TextUtils.isEmpty(shell.getContentViewCore().getWebContents( ).getUrl())) { | 111 if (TextUtils.isEmpty(shell.getContentViewCore().getWebContents( ).getUrl())) { |
| 111 updateFailureReason("Shell's URL is empty or null."); | 112 updateFailureReason("Shell's URL is empty or null."); |
| 112 return false; | 113 return false; |
| 113 } | 114 } |
| 114 return true; | 115 return true; |
| 115 } | 116 } |
| 116 }, WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT, CriteriaHelper.DEFAULT_POLLING _INTERVAL); | 117 }, WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT, CriteriaHelper.DEFAULT_POLLING _INTERVAL); |
| 117 } | 118 } |
| 118 | 119 |
| 120 OnCursorUpdateHelper getOnCursorUpdateHelper() throws ExecutionException { | |
| 121 return ThreadUtils | |
| 122 .runOnUiThreadBlocking(new Callable<Shell>() { | |
| 123 @Override | |
| 124 public Shell call() { | |
| 125 return mCallback.getActivityForTestCommon().getActiveShe ll(); | |
| 126 } | |
| 127 }) | |
| 128 .getViewAndroidDelegate() | |
|
boliu
2017/06/02 15:54:41
these two should be on UI thread as well
jaebaek
2017/06/03 14:24:10
Done.
| |
| 129 .getOnCursorUpdateHelper(); | |
| 130 } | |
| 131 | |
| 119 ContentViewCore getContentViewCore() { | 132 ContentViewCore getContentViewCore() { |
| 120 return mCallback.getActivityForTestCommon().getActiveShell().getContentV iewCore(); | 133 return mCallback.getActivityForTestCommon().getActiveShell().getContentV iewCore(); |
| 121 } | 134 } |
| 122 | 135 |
| 123 WebContents getWebContents() { | 136 WebContents getWebContents() { |
| 124 return mCallback.getActivityForTestCommon().getActiveShell().getWebConte nts(); | 137 return mCallback.getActivityForTestCommon().getActiveShell().getWebConte nts(); |
| 125 } | 138 } |
| 126 | 139 |
| 127 void loadUrl(final NavigationController navigationController, | 140 void loadUrl(final NavigationController navigationController, |
| 128 TestCallbackHelperContainer callbackHelperContainer, final LoadUrlPa rams params) | 141 TestCallbackHelperContainer callbackHelperContainer, final LoadUrlPa rams params) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 Instrumentation getInstrumentationForTestCommon(); | 204 Instrumentation getInstrumentationForTestCommon(); |
| 192 T launchActivityWithIntentForTestCommon(Intent t); | 205 T launchActivityWithIntentForTestCommon(Intent t); |
| 193 T getActivityForTestCommon(); | 206 T getActivityForTestCommon(); |
| 194 void runOnUiThreadForTestCommon(Runnable runnable) throws Throwable; | 207 void runOnUiThreadForTestCommon(Runnable runnable) throws Throwable; |
| 195 ContentViewCore getContentViewCoreForTestCommon(); | 208 ContentViewCore getContentViewCoreForTestCommon(); |
| 196 ContentShellActivity launchContentShellWithUrlForTestCommon(String url); | 209 ContentShellActivity launchContentShellWithUrlForTestCommon(String url); |
| 197 WebContents getWebContentsForTestCommon(); | 210 WebContents getWebContentsForTestCommon(); |
| 198 void waitForActiveShellToBeDoneLoadingForTestCommon(); | 211 void waitForActiveShellToBeDoneLoadingForTestCommon(); |
| 199 } | 212 } |
| 200 } | 213 } |
| OLD | NEW |