Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java

Issue 2831823003: Convert ChromeActivityTestCaseBase direct children to JUnit4 (Closed)
Patch Set: fix findbug issues Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java
index d1672343356625ba4a7525d52e4aa37aa0e04c0d..8d69ca6c9ed2e94570ef035382585502346e7b82 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java
@@ -11,16 +11,25 @@ import android.net.Uri;
import android.support.test.filters.SmallTest;
import android.widget.LinearLayout;
+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.Restriction;
import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.WebContentsFactory;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelManager;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelManagerWrapper;
import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.ContextualSearchPanel;
import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost;
-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.SelectionClient;
import org.chromium.content.browser.SelectionPopupController;
@@ -34,7 +43,13 @@ import javax.annotation.Nullable;
/**
* Mock touch events with Contextual Search to test behavior of its panel and manager.
*/
-public class ContextualSearchTapEventTest extends ChromeActivityTestCaseBase<ChromeActivity> {
+@RunWith(ChromeJUnit4ClassRunner.class)
+@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
+ ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
+public class ContextualSearchTapEventTest {
+ @Rule
+ public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
+ new ChromeActivityTestRule<>(ChromeActivity.class);
private ContextualSearchManagerWrapper mContextualSearchManager;
private ContextualSearchPanel mPanel;
@@ -222,15 +237,11 @@ public class ContextualSearchTapEventTest extends ChromeActivityTestCaseBase<Chr
// --------------------------------------------------------------------------------------------
- public ContextualSearchTapEventTest() {
- super(ChromeActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
+ mActivityTestRule.startMainActivityWithURL("about:blank");
Ted C 2017/04/27 18:05:26 we should use startMainActivityOnBlankPage since w
the real yoland 2017/04/28 02:03:28 Done
- final ChromeActivity activity = getActivity();
+ final ChromeActivity activity = mActivityTestRule.getActivity();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
@@ -250,33 +261,30 @@ public class ContextualSearchTapEventTest extends ChromeActivityTestCaseBase<Chr
});
}
- @Override
- public void startMainActivity() throws InterruptedException {
- startMainActivityWithURL("about:blank");
- }
-
/**
* Tests that a Tap gesture followed by tapping empty space closes the panel.
*/
+ @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
public void testTextTapFollowedByNonTextTap() {
- assertTrue(mPanelManager.getRequestPanelShowCount() == 0);
+ Assert.assertTrue(mPanelManager.getRequestPanelShowCount() == 0);
Ted C 2017/04/27 18:05:27 if you were inclined, all these assertTrues here s
the real yoland 2017/04/28 02:03:28 Done
// Fake a selection event.
mockTapText("text");
- assertTrue(mPanelManager.getRequestPanelShowCount() == 1);
- assertTrue(mPanelManager.getPanelHideCount() == 0);
- assertTrue(mContextualSearchManager.getSelectionController().getSelectedText()
- .equals("text"));
+ Assert.assertTrue(mPanelManager.getRequestPanelShowCount() == 1);
+ Assert.assertTrue(mPanelManager.getPanelHideCount() == 0);
+ Assert.assertTrue(
+ mContextualSearchManager.getSelectionController().getSelectedText().equals("text"));
// Fake tap on non-text.
mockTapEmptySpace();
- assertTrue(mPanelManager.getRequestPanelShowCount() == 1);
- assertTrue(mPanelManager.getPanelHideCount() == 1);
- assertTrue(mContextualSearchManager.getSelectionController().getSelectedText() == null);
+ Assert.assertTrue(mPanelManager.getRequestPanelShowCount() == 1);
+ Assert.assertTrue(mPanelManager.getPanelHideCount() == 1);
+ Assert.assertTrue(
+ mContextualSearchManager.getSelectionController().getSelectedText() == null);
}
}

Powered by Google App Engine
This is Rietveld 408576698