Index: chrome/android/javatests/src/org/chromium/chrome/browser/NavigationPopupTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/NavigationPopupTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/NavigationPopupTest.java |
index d50d9ee5f189486ee032fe0bf78281af2752a3ce..682f709a0761ebb0640b03f7e547c9a5eee96699 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/NavigationPopupTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/NavigationPopupTest.java |
@@ -8,20 +8,12 @@ |
import android.support.test.filters.MediumTest; |
import android.support.test.filters.SmallTest; |
-import org.junit.Assert; |
-import org.junit.Before; |
-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.profiles.Profile; |
-import org.chromium.chrome.test.ChromeActivityTestRule; |
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
+import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
import org.chromium.content.browser.test.util.Criteria; |
import org.chromium.content.browser.test.util.CriteriaHelper; |
import org.chromium.content_public.browser.LoadUrlParams; |
@@ -29,33 +21,34 @@ |
import org.chromium.content_public.browser.NavigationEntry; |
import org.chromium.content_public.browser.NavigationHistory; |
-import java.util.concurrent.atomic.AtomicReference; |
- |
/** |
* Tests for the navigation popup. |
*/ |
-@RunWith(ChromeJUnit4ClassRunner.class) |
@RetryOnFailure |
-@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
-public class NavigationPopupTest { |
- @Rule |
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = |
- new ChromeActivityTestRule<>(ChromeActivity.class); |
+public class NavigationPopupTest extends ChromeActivityTestCaseBase<ChromeActivity> { |
private static final int INVALID_NAVIGATION_INDEX = -1; |
private Profile mProfile; |
- @Before |
- public void setUp() throws Exception { |
- mActivityTestRule.startMainActivityOnBlankPage(); |
+ public NavigationPopupTest() { |
+ super(ChromeActivity.class); |
+ } |
+ |
+ @Override |
+ protected void setUp() throws Exception { |
+ super.setUp(); |
ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
@Override |
public void run() { |
mProfile = Profile.getLastUsedProfile(); |
} |
}); |
+ } |
+ |
+ @Override |
+ public void startMainActivity() throws InterruptedException { |
+ startMainActivityOnBlankPage(); |
} |
// Exists solely to expose protected methods to this test. |
@@ -230,25 +223,19 @@ |
public void setEntryExtraData(int index, String key, String value) {} |
} |
- @Test |
@MediumTest |
@Feature({"Navigation"}) |
public void testFaviconFetching() { |
final TestNavigationController controller = new TestNavigationController(); |
- final AtomicReference<NavigationPopup> popupReference = new AtomicReference<>(); |
- ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
- @Override |
- public void run() { |
- NavigationPopup popup = new NavigationPopup( |
- mProfile, mActivityTestRule.getActivity(), controller, true); |
- popup.setWidth(300); |
- popup.setHeight(300); |
- popup.setAnchorView(mActivityTestRule.getActivity() |
- .getCurrentContentViewCore() |
- .getContainerView()); |
- |
+ final NavigationPopup popup = new NavigationPopup( |
+ mProfile, getActivity(), controller, true); |
+ popup.setWidth(300); |
+ popup.setHeight(300); |
+ popup.setAnchorView(getActivity().getCurrentContentViewCore().getContainerView()); |
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
+ @Override |
+ public void run() { |
popup.show(); |
- popupReference.set(popup); |
} |
}); |
@@ -268,43 +255,37 @@ |
ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
@Override |
public void run() { |
- popupReference.get().dismiss(); |
- } |
- }); |
- } |
- |
- @Test |
+ popup.dismiss(); |
+ } |
+ }); |
+ } |
+ |
@SmallTest |
@Feature({"Navigation"}) |
public void testItemSelection() { |
final TestNavigationController controller = new TestNavigationController(); |
- final AtomicReference<NavigationPopup> popupReference = new AtomicReference<>(); |
- ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
- @Override |
- public void run() { |
- NavigationPopup popup = new NavigationPopup( |
- mProfile, mActivityTestRule.getActivity(), controller, true); |
- popup.setWidth(300); |
- popup.setHeight(300); |
- popup.setAnchorView(mActivityTestRule.getActivity() |
- .getCurrentContentViewCore() |
- .getContainerView()); |
- |
+ final NavigationPopup popup = |
+ new NavigationPopup(mProfile, getActivity(), controller, true); |
+ popup.setWidth(300); |
+ popup.setHeight(300); |
+ popup.setAnchorView(getActivity().getCurrentContentViewCore().getContainerView()); |
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
+ @Override |
+ public void run() { |
popup.show(); |
- popupReference.set(popup); |
- } |
- }); |
- |
- ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
- @Override |
- public void run() { |
- popupReference.get().performItemClick(1); |
- } |
- }); |
- |
- Assert.assertFalse("Popup did not hide as expected.", popupReference.get().isShowing()); |
- Assert.assertEquals( |
- "Popup attempted to navigate to the wrong index", 5, controller.mNavigatedIndex); |
+ } |
+ }); |
+ |
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
+ @Override |
+ public void run() { |
+ popup.performItemClick(1); |
+ } |
+ }); |
+ |
+ assertFalse("Popup did not hide as expected.", popup.isShowing()); |
+ assertEquals("Popup attempted to navigate to the wrong index", 5, |
+ controller.mNavigatedIndex); |
} |
} |