Index: chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java |
index 3bb348c87e1ce225668d83e5584685e5e14a3ef9..a64931a13bbefce95b3fbc00c47d05cbdfcd392d 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java |
@@ -4,15 +4,24 @@ |
package org.chromium.chrome.browser.input; |
+import android.support.test.InstrumentationRegistry; |
import android.support.test.filters.LargeTest; |
+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.Feature; |
import org.chromium.base.test.util.RetryOnFailure; |
import org.chromium.base.test.util.UrlUtils; |
import org.chromium.chrome.browser.ChromeActivity; |
+import org.chromium.chrome.browser.ChromeSwitches; |
import org.chromium.chrome.browser.WebContentsFactory; |
-import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
+import org.chromium.chrome.test.ChromeActivityTestRule; |
+import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
import org.chromium.content.browser.ContentView; |
import org.chromium.content.browser.ContentViewCore; |
import org.chromium.content.browser.test.util.Criteria; |
@@ -26,7 +35,14 @@ import org.chromium.ui.base.WindowAndroid; |
/** |
* Test the select popup and how it interacts with another ContentViewCore. |
*/ |
-public class SelectPopupOtherContentViewTest extends ChromeActivityTestCaseBase<ChromeActivity> { |
+@RunWith(ChromeJUnit4ClassRunner.class) |
+@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
+ ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
+public class SelectPopupOtherContentViewTest { |
+ @Rule |
+ public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = |
+ new ChromeActivityTestRule<>(ChromeActivity.class); |
+ |
private static final String SELECT_URL = UrlUtils.encodeHtmlDataUri( |
"<html><body>" |
+ "Which animal is the strongest:<br/>" |
@@ -48,34 +64,28 @@ public class SelectPopupOtherContentViewTest extends ChromeActivityTestCaseBase< |
@Override |
public boolean isSatisfied() { |
- ContentViewCore contentViewCore = getActivity().getCurrentContentViewCore(); |
+ ContentViewCore contentViewCore = |
+ mActivityTestRule.getActivity().getCurrentContentViewCore(); |
return contentViewCore.getSelectPopupForTest() != null; |
} |
} |
- public SelectPopupOtherContentViewTest() { |
- super(ChromeActivity.class); |
- } |
- |
- @Override |
- public void startMainActivity() throws InterruptedException { |
- // Don't launch activity automatically. |
- } |
- |
/** |
* Tests that the showing select popup does not get closed because an unrelated ContentView |
* gets destroyed. |
* |
*/ |
+ @Test |
@LargeTest |
@Feature({"Browser"}) |
@RetryOnFailure |
public void testPopupNotClosedByOtherContentView() |
throws InterruptedException, Exception, Throwable { |
// Load the test page. |
- startMainActivityWithURL(SELECT_URL); |
+ mActivityTestRule.startMainActivityWithURL(SELECT_URL); |
- final ContentViewCore viewCore = getActivity().getCurrentContentViewCore(); |
+ final ContentViewCore viewCore = |
+ mActivityTestRule.getActivity().getCurrentContentViewCore(); |
// Once clicked, the popup should show up. |
DOMUtils.clickNode(viewCore, "select"); |
@@ -86,10 +96,13 @@ public class SelectPopupOtherContentViewTest extends ChromeActivityTestCaseBase< |
@Override |
public void run() { |
WebContents webContents = WebContentsFactory.createWebContents(false, false); |
- WindowAndroid windowAndroid = new ActivityWindowAndroid(getActivity()); |
+ WindowAndroid windowAndroid = |
+ new ActivityWindowAndroid(mActivityTestRule.getActivity()); |
- ContentViewCore contentViewCore = new ContentViewCore(getActivity(), ""); |
- ContentView cv = ContentView.createContentView(getActivity(), contentViewCore); |
+ ContentViewCore contentViewCore = |
+ new ContentViewCore(mActivityTestRule.getActivity(), ""); |
+ ContentView cv = ContentView.createContentView( |
+ mActivityTestRule.getActivity(), contentViewCore); |
contentViewCore.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, |
webContents, windowAndroid); |
contentViewCore.destroy(); |
@@ -97,10 +110,11 @@ public class SelectPopupOtherContentViewTest extends ChromeActivityTestCaseBase< |
}); |
// Process some more events to give a chance to the dialog to hide if it were to. |
- getInstrumentation().waitForIdleSync(); |
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync(); |
// The popup should still be shown. |
- assertNotNull("The select popup got hidden by destroying of unrelated ContentViewCore.", |
+ Assert.assertNotNull( |
+ "The select popup got hidden by destroying of unrelated ContentViewCore.", |
viewCore.getSelectPopupForTest()); |
} |
} |