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

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

Issue 2860843002: Revert of Reland: Convert ChromeActivityTestCaseBase direct children to JUnit4 (Closed)
Patch Set: 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/ContextualSearchManagerTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java
index cb4421cba98001f62f549dbca43d501837354175..7b8c14bc6239c8b00a3ea2f748d120b09230a474 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java
@@ -16,19 +16,11 @@
import android.content.SharedPreferences;
import android.graphics.Point;
import android.os.SystemClock;
-import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewConfiguration;
-
-import org.junit.After;
-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.ContextUtils;
import org.chromium.base.ThreadUtils;
@@ -42,7 +34,6 @@
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
-import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate;
import org.chromium.chrome.browser.compositor.bottombar.OverlayContentProgressObserver;
@@ -63,8 +54,7 @@
import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.chrome.browser.tabmodel.TabModelUtils;
-import org.chromium.chrome.test.ChromeActivityTestRule;
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
import org.chromium.chrome.test.util.ChromeRestriction;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.FullscreenTestUtils;
@@ -94,17 +84,10 @@
* Tests the Contextual Search Manager using instrumentation tests.
*/
// NOTE: Disable online detection so we we'll default to online on test bots with no network.
-@RunWith(ChromeJUnit4ClassRunner.class)
-@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG,
- ContextualSearchFieldTrial.ONLINE_DETECTION_DISABLED})
@Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
+@CommandLineFlags.Add(ContextualSearchFieldTrial.ONLINE_DETECTION_DISABLED)
@RetryOnFailure
-public class ContextualSearchManagerTest {
- @Rule
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
- new ChromeActivityTestRule<>(ChromeActivity.class);
-
+public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<ChromeActivity> {
private static final String TEST_PAGE =
"/chrome/test/data/android/contextualsearch/tap_test.html";
private static final int TEST_TIMEOUT = 15000;
@@ -133,11 +116,14 @@
// State for an individual test.
FakeSlowResolveSearch mLatestSlowResolveSearch;
- @Before
- public void setUp() throws Exception {
+ public ContextualSearchManagerTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
// We have to set up the test server before starting the activity.
- mTestServer = EmbeddedTestServer.createAndStartServer(
- InstrumentationRegistry.getInstrumentation().getContext());
+ mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
@@ -145,14 +131,11 @@
FirstRunStatus.setFirstRunFlowComplete(true);
}
});
- mActivityTestRule.startMainActivityWithURL(mTestServer.getURL(TEST_PAGE));
- // There's a problem with immediate startup that causes flakes due to the page not being
- // ready, so specify a startup-delay of 1000 for legacy behavior. See crbug.com/635661.
- // TODO(donnd): find a better way to wait for page-ready, or at least reduce the delay!
- Thread.sleep(ACTIVITY_STARTUP_DELAY_MS);
- mManager = mActivityTestRule.getActivity().getContextualSearchManager();
-
- Assert.assertNotNull(mManager);
+ super.setUp();
+
+ mManager = getActivity().getContextualSearchManager();
+
+ assertNotNull(mManager);
mPanel = mManager.getContextualSearchPanel();
mSelectionController = mManager.getSelectionController();
@@ -162,7 +145,7 @@
mFakeServer = new ContextualSearchFakeServer(mPolicy, this, mManager,
mManager.getOverlayContentDelegate(), new OverlayContentProgressObserver(),
- mActivityTestRule.getActivity());
+ getActivity());
mPanel.setOverlayPanelContentFactory(mFakeServer);
mManager.setNetworkCommunicator(mFakeServer);
@@ -172,14 +155,14 @@
IntentFilter filter = new IntentFilter(Intent.ACTION_VIEW);
filter.addCategory(Intent.CATEGORY_BROWSABLE);
filter.addDataScheme("market");
- mActivityMonitor = InstrumentationRegistry.getInstrumentation().addMonitor(
+ mActivityMonitor = getInstrumentation().addMonitor(
filter, new Instrumentation.ActivityResult(Activity.RESULT_OK, null), true);
- mDpToPx = mActivityTestRule.getActivity().getResources().getDisplayMetrics().density;
- }
-
- @After
- public void tearDown() throws Exception {
+ mDpToPx = getActivity().getResources().getDisplayMetrics().density;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
mTestServer.stopAndDestroyServer();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
@@ -187,6 +170,7 @@
FirstRunStatus.setFirstRunFlowComplete(false);
}
});
+ super.tearDown();
}
/**
@@ -199,7 +183,7 @@
throws InterruptedException, TimeoutException {
mFakeServer.setIsOnline(isOnline);
final String testUrl = mTestServer.getURL(TEST_PAGE);
- final Tab tab = mActivityTestRule.getActivity().getActivityTab();
+ final Tab tab = getActivity().getActivityTab();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
@@ -220,7 +204,7 @@
*/
public void longPressNodeWithoutWaiting(String nodeId)
throws InterruptedException, TimeoutException {
- Tab tab = mActivityTestRule.getActivity().getActivityTab();
+ Tab tab = getActivity().getActivityTab();
DOMUtils.longPressNode(tab.getContentViewCore(), nodeId);
}
@@ -238,7 +222,7 @@
* @param nodeId A string containing the node ID.
*/
public void clickNode(String nodeId) throws InterruptedException, TimeoutException {
- Tab tab = mActivityTestRule.getActivity().getActivityTab();
+ Tab tab = getActivity().getActivityTab();
DOMUtils.clickNode(tab.getContentViewCore(), nodeId);
}
@@ -308,7 +292,16 @@
* @param runnable The Runnable.
*/
public void runOnMainSync(Runnable runnable) {
- InstrumentationRegistry.getInstrumentation().runOnMainSync(runnable);
+ getInstrumentation().runOnMainSync(runnable);
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityWithURL(mTestServer.getURL(TEST_PAGE));
+ // There's a problem with immediate startup that causes flakes due to the page not being
+ // ready, so specify a startup-delay of 1000 for legacy behavior. See crbug.com/635661.
+ // TODO(donnd): find a better way to wait for page-ready, or at least reduce the delay!
+ Thread.sleep(ACTIVITY_STARTUP_DELAY_MS);
}
//============================================================================================
@@ -467,10 +460,10 @@
int startAdjust, int endAdjust, String contextLanguage, String thumbnailUrl,
String caption, String quickActionUri, int quickActionCategory) {
if (mFakeServer.getSearchTermRequested() != null) {
- InstrumentationRegistry.getInstrumentation().runOnMainSync(new FakeResponseOnMainThread(
- isNetworkUnavailable, responseCode, searchTerm, displayText, alternateTerm, mid,
- doPreventPreload, startAdjust, endAdjust, contextLanguage, thumbnailUrl,
- caption, quickActionUri, quickActionCategory));
+ getInstrumentation().runOnMainSync(new FakeResponseOnMainThread(isNetworkUnavailable,
+ responseCode, searchTerm, displayText, alternateTerm, mid, doPreventPreload,
+ startAdjust, endAdjust, contextLanguage, thumbnailUrl, caption,
+ quickActionUri, quickActionCategory));
}
}
@@ -498,28 +491,28 @@
* Asserts that the Panel's ContentViewCore is created.
*/
private void assertContentViewCoreCreated() {
- Assert.assertNotNull(getPanelContentViewCore());
+ assertNotNull(getPanelContentViewCore());
}
/**
* Asserts that the Panel's ContentViewCore is not created.
*/
private void assertNoContentViewCore() {
- Assert.assertNull(getPanelContentViewCore());
+ assertNull(getPanelContentViewCore());
}
/**
* Asserts that the Panel's ContentViewCore is visible.
*/
private void assertContentViewCoreVisible() {
- Assert.assertTrue(isContentViewCoreVisible());
+ assertTrue(isContentViewCoreVisible());
}
/**
* Asserts that the Panel's ContentViewCore onShow() method was never called.
*/
private void assertNeverCalledContentViewCoreOnShow() {
- Assert.assertFalse(mFakeServer.didEverCallContentViewCoreOnShow());
+ assertFalse(mFakeServer.didEverCallContentViewCoreOnShow());
}
/**
@@ -527,7 +520,7 @@
*/
private void assertContentViewCoreCreatedButNeverMadeVisible() {
assertContentViewCoreCreated();
- Assert.assertFalse(isContentViewCoreVisible());
+ assertFalse(isContentViewCoreVisible());
assertNeverCalledContentViewCoreOnShow();
}
@@ -585,8 +578,7 @@
* @param keycode The key's code.
*/
private void pressKey(int keycode) {
- KeyUtils.singleKeyEventActivity(InstrumentationRegistry.getInstrumentation(),
- mActivityTestRule.getActivity(), keycode);
+ KeyUtils.singleKeyEventActivity(getInstrumentation(), getActivity(), keycode);
}
/**
@@ -613,15 +605,14 @@
doesMatch = loadedUrl != null && loadedUrl.contains("q=" + searchTerm);
String message = loadedUrl == null ? "but there was no loaded URL!"
: "in URL: " + loadedUrl;
- Assert.assertTrue(
- "Expected to find searchTerm '" + searchTerm + "', " + message, doesMatch);
+ assertTrue("Expected to find searchTerm '" + searchTerm + "', " + message, doesMatch);
}
/**
* Asserts that the given parameters are present in the most recently loaded URL.
*/
private void assertContainsParameters(String searchTerm, String alternateTerm) {
- Assert.assertTrue(mFakeServer.getSearchTermRequested() == null
+ assertTrue(mFakeServer.getSearchTermRequested() == null
|| mFakeServer.getLoadedUrl().contains(searchTerm)
&& mFakeServer.getLoadedUrl().contains(alternateTerm));
}
@@ -630,14 +621,14 @@
* Asserts that a Search Term has been requested.
*/
private void assertSearchTermRequested() {
- Assert.assertNotNull(mFakeServer.getSearchTermRequested());
+ assertNotNull(mFakeServer.getSearchTermRequested());
}
/**
* Asserts that there has not been any Search Term requested.
*/
private void assertSearchTermNotRequested() {
- Assert.assertNull(mFakeServer.getSearchTermRequested());
+ assertNull(mFakeServer.getSearchTermRequested());
}
/**
@@ -651,21 +642,21 @@
PanelState panelState = mPanel.getPanelState();
success = panelState == PanelState.CLOSED || panelState == PanelState.UNDEFINED;
}
- Assert.assertTrue(success);
+ assertTrue(success);
}
/**
* Asserts that the panel is currently in the "peeking" state (just showing the Bar).
*/
private void assertPanelPeeked() {
- Assert.assertTrue(mPanel.getPanelState() == PanelState.PEEKED);
+ assertTrue(mPanel.getPanelState() == PanelState.PEEKED);
}
/**
* Asserts that no URL has been loaded in the Overlay Panel.
*/
private void assertLoadedNoUrl() {
- Assert.assertTrue("Requested a search or preload when none was expected!",
+ assertTrue("Requested a search or preload when none was expected!",
mFakeServer.getLoadedUrl() == null);
}
@@ -675,10 +666,9 @@
private void assertLoadedLowPriorityUrl() {
String message = "Expected a low priority search request URL, but got "
+ (mFakeServer.getLoadedUrl() != null ? mFakeServer.getLoadedUrl() : "null");
- Assert.assertTrue(message,
- mFakeServer.getLoadedUrl() != null
- && mFakeServer.getLoadedUrl().contains(LOW_PRIORITY_SEARCH_ENDPOINT));
- Assert.assertTrue("Low priority request does not have the required prefetch parameter!",
+ assertTrue(message, mFakeServer.getLoadedUrl() != null
+ && mFakeServer.getLoadedUrl().contains(LOW_PRIORITY_SEARCH_ENDPOINT));
+ assertTrue("Low priority request does not have the required prefetch parameter!",
mFakeServer.getLoadedUrl() != null
&& mFakeServer.getLoadedUrl().contains(CONTEXTUAL_SEARCH_PREFETCH_PARAM));
}
@@ -690,11 +680,10 @@
private void assertLoadedLowPriorityInvalidUrl() {
String message = "Expected a low priority invalid search request URL, but got "
+ (String.valueOf(mFakeServer.getLoadedUrl()));
- Assert.assertTrue(message,
- mFakeServer.getLoadedUrl() != null
+ assertTrue(message, mFakeServer.getLoadedUrl() != null
&& mFakeServer.getLoadedUrl().contains(
LOW_PRIORITY_INVALID_SEARCH_ENDPOINT));
- Assert.assertTrue("Low priority request does not have the required prefetch parameter!",
+ assertTrue("Low priority request does not have the required prefetch parameter!",
mFakeServer.getLoadedUrl() != null
&& mFakeServer.getLoadedUrl().contains(CONTEXTUAL_SEARCH_PREFETCH_PARAM));
}
@@ -705,11 +694,9 @@
private void assertLoadedNormalPriorityUrl() {
String message = "Expected a normal priority search request URL, but got "
+ (mFakeServer.getLoadedUrl() != null ? mFakeServer.getLoadedUrl() : "null");
- Assert.assertTrue(message,
- mFakeServer.getLoadedUrl() != null
- && mFakeServer.getLoadedUrl().contains(NORMAL_PRIORITY_SEARCH_ENDPOINT));
- Assert.assertTrue(
- "Normal priority request should not have the prefetch parameter, but did!",
+ assertTrue(message, mFakeServer.getLoadedUrl() != null
+ && mFakeServer.getLoadedUrl().contains(NORMAL_PRIORITY_SEARCH_ENDPOINT));
+ assertTrue("Normal priority request should not have the prefetch parameter, but did!",
mFakeServer.getLoadedUrl() != null
&& !mFakeServer.getLoadedUrl().contains(CONTEXTUAL_SEARCH_PREFETCH_PARAM));
}
@@ -718,7 +705,7 @@
* Asserts that no URLs have been loaded in the Overlay Panel since the last {@link reset}.
*/
private void assertNoSearchesLoaded() {
- Assert.assertEquals(0, mFakeServer.getLoadedUrlCount());
+ assertEquals(0, mFakeServer.getLoadedUrlCount());
assertLoadedNoUrl();
}
@@ -726,16 +713,16 @@
* Asserts that the tap triggered promo counter is enabled and at the specified count.
*/
private void assertTapPromoCounterEnabledAt(int expectedCount) {
- Assert.assertTrue(mPolicy.getPromoTapCounter().isEnabled());
- Assert.assertEquals(expectedCount, mPolicy.getPromoTapCounter().getCount());
+ assertTrue(mPolicy.getPromoTapCounter().isEnabled());
+ assertEquals(expectedCount, mPolicy.getPromoTapCounter().getCount());
}
/**
* Asserts that the tap triggered promo counter is disabled and at the specified count.
*/
private void assertTapPromoCounterDisabledAt(int expectedCount) {
- Assert.assertFalse(mPolicy.getPromoTapCounter().isEnabled());
- Assert.assertEquals(expectedCount, mPolicy.getPromoTapCounter().getCount());
+ assertFalse(mPolicy.getPromoTapCounter().isEnabled());
+ assertEquals(expectedCount, mPolicy.getPromoTapCounter().getCount());
}
/**
@@ -809,7 +796,7 @@
Thread.sleep(DEFAULT_POLLING_INTERVAL);
didChangeState = mPanel.getPanelState() != initialState;
}
- Assert.assertFalse(didChangeState);
+ assertFalse(didChangeState);
}
/**
@@ -838,7 +825,7 @@
waitForGestureProcessing();
waitForPanelToClose();
assertPanelClosedOrUndefined();
- Assert.assertTrue(TextUtils.isEmpty(getSelectedText()));
+ assertTrue(TextUtils.isEmpty(getSelectedText()));
}
/**
@@ -879,16 +866,15 @@
*/
private void fling(float startX, float startY, float endX, float endY, int stepCount) {
Point size = new Point();
- mActivityTestRule.getActivity().getWindowManager().getDefaultDisplay().getSize(size);
+ getActivity().getWindowManager().getDefaultDisplay().getSize(size);
float dragStartX = size.x * startX;
float dragEndX = size.x * endX;
float dragStartY = size.y * startY;
float dragEndY = size.y * endY;
long downTime = SystemClock.uptimeMillis();
- TouchCommon.dragStart(mActivityTestRule.getActivity(), dragStartX, dragStartY, downTime);
- TouchCommon.dragTo(mActivityTestRule.getActivity(), dragStartX, dragEndX, dragStartY,
- dragEndY, stepCount, downTime);
- TouchCommon.dragEnd(mActivityTestRule.getActivity(), dragEndX, dragEndY, downTime);
+ dragStart(dragStartX, dragStartY, downTime);
+ dragTo(dragStartX, dragEndX, dragStartY, dragEndY, stepCount, downTime);
+ dragEnd(dragEndX, dragEndY, downTime);
}
/**
@@ -897,21 +883,19 @@
*/
private void swipe(float startX, float startY, float endX, float endY, int stepCount) {
Point size = new Point();
- mActivityTestRule.getActivity().getWindowManager().getDefaultDisplay().getSize(size);
+ getActivity().getWindowManager().getDefaultDisplay().getSize(size);
float dragStartX = size.x * startX;
float dragEndX = size.x * endX;
float dragStartY = size.y * startY;
float dragEndY = size.y * endY;
int halfCount = stepCount / 2;
long downTime = SystemClock.uptimeMillis();
- TouchCommon.dragStart(mActivityTestRule.getActivity(), dragStartX, dragStartY, downTime);
- TouchCommon.dragTo(mActivityTestRule.getActivity(), dragStartX, dragEndX, dragStartY,
- dragEndY, halfCount, downTime);
+ dragStart(dragStartX, dragStartY, downTime);
+ dragTo(dragStartX, dragEndX, dragStartY, dragEndY, halfCount, downTime);
// Generate events in the stationary end position in order to simulate a "pause" in
// the movement, therefore preventing this gesture from being interpreted as a fling.
- TouchCommon.dragTo(mActivityTestRule.getActivity(), dragEndX, dragEndX, dragEndY, dragEndY,
- halfCount, downTime);
- TouchCommon.dragEnd(mActivityTestRule.getActivity(), dragEndX, dragEndY, downTime);
+ dragTo(dragEndX, dragEndX, dragEndY, dragEndY, halfCount, downTime);
+ dragEnd(dragEndX, dragEndY, downTime);
}
/**
@@ -965,7 +949,7 @@
* Taps the base page at the given x, y position.
*/
private void tapBasePage(float x, float y) {
- View root = mActivityTestRule.getActivity().getWindow().getDecorView().getRootView();
+ View root = getActivity().getWindow().getDecorView().getRootView();
x *= root.getWidth();
y *= root.getHeight();
TouchCommon.singleClickView(root, (int) x, (int) y);
@@ -993,7 +977,7 @@
* TODO(donnd): Replace this method with panelBarClick since this appears to be unreliable.
*/
private void clickPanelBar() {
- View root = mActivityTestRule.getActivity().getWindow().getDecorView().getRootView();
+ View root = getActivity().getWindow().getDecorView().getRootView();
float tapX = ((mPanel.getOffsetX() + mPanel.getWidth()) / 2f) * mDpToPx;
float tapY = (mPanel.getOffsetY() + (mPanel.getBarContainerHeight() / 2f)) * mDpToPx;
@@ -1073,7 +1057,7 @@
* @throws InterruptedException
*/
private void forcePanelToHandleBarClick() throws InterruptedException {
- InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
+ getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
// TODO(donnd): provide better time and x,y data to make this more broadly useful.
@@ -1087,7 +1071,7 @@
* @throws InterruptedException
*/
private void closePanel() throws InterruptedException {
- InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
+ getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
mPanel.closePanel(StateChangeReason.UNKNOWN, false);
@@ -1111,18 +1095,16 @@
*/
//@SmallTest
//@Feature({"ContextualSearch"})
- @Test
@DisabledTest
public void testHidesWhenOmniboxFocused() throws InterruptedException, TimeoutException {
clickWordNode("intelligence");
- Assert.assertEquals("Intelligence", mFakeServer.getSearchTermRequested());
+ assertEquals("Intelligence", mFakeServer.getSearchTermRequested());
fakeResponse(false, 200, "Intelligence", "display-text", "alternate-term", false);
assertContainsParameters("Intelligence", "alternate-term");
waitForPanelToPeek();
- OmniboxTestUtils.toggleUrlBarFocus(
- (UrlBar) mActivityTestRule.getActivity().findViewById(R.id.url_bar), true);
+ OmniboxTestUtils.toggleUrlBarFocus((UrlBar) getActivity().findViewById(R.id.url_bar), true);
assertPanelClosedOrUndefined();
}
@@ -1130,56 +1112,53 @@
/**
* Tests the doesContainAWord method.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testDoesContainAWord() {
- Assert.assertTrue(mSelectionController.doesContainAWord("word"));
- Assert.assertTrue(mSelectionController.doesContainAWord("word "));
- Assert.assertFalse("Emtpy string should not be considered a word!",
+ assertTrue(mSelectionController.doesContainAWord("word"));
+ assertTrue(mSelectionController.doesContainAWord("word "));
+ assertFalse("Emtpy string should not be considered a word!",
mSelectionController.doesContainAWord(""));
- Assert.assertFalse("Special symbols should not be considered a word!",
+ assertFalse("Special symbols should not be considered a word!",
mSelectionController.doesContainAWord("@"));
- Assert.assertFalse("White space should not be considered a word",
+ assertFalse("White space should not be considered a word",
mSelectionController.doesContainAWord(" "));
- Assert.assertTrue(mSelectionController.doesContainAWord("Q2"));
- Assert.assertTrue(mSelectionController.doesContainAWord("123"));
+ assertTrue(mSelectionController.doesContainAWord("Q2"));
+ assertTrue(mSelectionController.doesContainAWord("123"));
}
/**
* Tests the isValidSelection method.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testIsValidSelection() {
- StubbedContentViewCore stubbedCvc =
- new StubbedContentViewCore(mActivityTestRule.getActivity().getBaseContext());
- Assert.assertTrue(mSelectionController.isValidSelection("valid", stubbedCvc));
- Assert.assertFalse(mSelectionController.isValidSelection(" ", stubbedCvc));
+ StubbedContentViewCore stubbedCvc = new StubbedContentViewCore(
+ getActivity().getBaseContext());
+ assertTrue(mSelectionController.isValidSelection("valid", stubbedCvc));
+ assertFalse(mSelectionController.isValidSelection(" ", stubbedCvc));
stubbedCvc.setIsFocusedNodeEditableForTest(true);
- Assert.assertFalse(mSelectionController.isValidSelection("editable", stubbedCvc));
+ assertFalse(mSelectionController.isValidSelection("editable", stubbedCvc));
stubbedCvc.setIsFocusedNodeEditableForTest(false);
String numberString = "0123456789";
StringBuilder longStringBuilder = new StringBuilder();
for (int i = 0; i < 11; i++) {
longStringBuilder.append(numberString);
}
- Assert.assertTrue(mSelectionController.isValidSelection(numberString, stubbedCvc));
- Assert.assertFalse(
- mSelectionController.isValidSelection(longStringBuilder.toString(), stubbedCvc));
+ assertTrue(mSelectionController.isValidSelection(numberString, stubbedCvc));
+ assertFalse(mSelectionController.isValidSelection(longStringBuilder.toString(),
+ stubbedCvc));
}
/**
* Tests a simple Tap.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTap() throws InterruptedException, TimeoutException {
clickWordNode("intelligence");
- Assert.assertEquals("Intelligence", mFakeServer.getSearchTermRequested());
+ assertEquals("Intelligence", mFakeServer.getSearchTermRequested());
fakeResponse(false, 200, "Intelligence", "display-text", "alternate-term", false);
assertContainsParameters("Intelligence", "alternate-term");
waitForPanelToPeek();
@@ -1189,13 +1168,12 @@
/**
* Tests a simple Long-Press gesture, without opening the panel.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testLongPress() throws InterruptedException, TimeoutException {
longPressNode("states");
- Assert.assertNull(mFakeServer.getSearchTermRequested());
+ assertNull(mFakeServer.getSearchTermRequested());
waitForPanelToPeek();
assertLoadedNoUrl();
assertNoContentViewCore();
@@ -1204,7 +1182,6 @@
/**
* Tests swiping the overlay open, after an initial tap that activates the peeking card.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -1217,13 +1194,13 @@
fakeResponse(false, 200, "Intelligence", "United States Intelligence", "alternate-term",
false);
assertContainsParameters("Intelligence", "alternate-term");
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
assertLoadedLowPriorityUrl();
waitForPanelToPeek();
flingPanelUp();
waitForPanelToExpand();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
assertLoadedLowPriorityUrl();
}
@@ -1233,7 +1210,6 @@
* This test also verifies that we don't create any {@link ContentViewCore} or load any URL
* until the panel is opened.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -1245,18 +1221,17 @@
tapPeekingBarToExpandAndAssert();
assertContentViewCoreCreated();
assertLoadedNormalPriorityUrl();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// tap the base page to close.
closePanel();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
assertNoContentViewCore();
}
/**
* Tests that only a single low-priority request is issued for a Tap/Open sequence.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapCausesOneLowPriorityRequest() throws InterruptedException, TimeoutException {
@@ -1265,27 +1240,26 @@
// We should not make a second-request until we get a good response from the first-request.
assertLoadedNoUrl();
- Assert.assertEquals(0, mFakeServer.getLoadedUrlCount());
+ assertEquals(0, mFakeServer.getLoadedUrlCount());
fakeResponse(false, 200, "states", "United States Intelligence", "alternate-term", false);
assertLoadedLowPriorityUrl();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// When the second request succeeds, we should not issue a new request.
fakeContentViewDidNavigate(false);
assertLoadedLowPriorityUrl();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// When the bar opens, we should not make any additional request.
tapPeekingBarToExpandAndAssert();
assertLoadedLowPriorityUrl();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
assertLoadedLowPriorityUrl();
}
/**
* Tests that a failover for a prefetch request is issued after the panel is opened.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testPrefetchFailoverRequestMadeAfterOpen()
@@ -1295,27 +1269,26 @@
// We should not make a SERP request until we get a good response from the resolve request.
assertLoadedNoUrl();
- Assert.assertEquals(0, mFakeServer.getLoadedUrlCount());
+ assertEquals(0, mFakeServer.getLoadedUrlCount());
fakeResponse(false, 200, "states", "United States Intelligence", "alternate-term", false);
assertLoadedLowPriorityUrl();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// When the second request fails, we should not automatically issue a new request.
fakeContentViewDidNavigate(true);
assertLoadedLowPriorityUrl();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Once the bar opens, we make a new request at normal priority.
tapPeekingBarToExpandAndAssert();
assertLoadedNormalPriorityUrl();
- Assert.assertEquals(2, mFakeServer.getLoadedUrlCount());
+ assertEquals(2, mFakeServer.getLoadedUrlCount());
}
/**
* Tests that a live request that fails (for an invalid URL) does a failover to a
* normal priority request once the user triggers the failover by opening the panel.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testLivePrefetchFailoverRequestMadeAfterOpen()
@@ -1324,10 +1297,10 @@
mFakeServer.setLowPriorityPathInvalid();
simulateTapSearch("search");
assertLoadedLowPriorityInvalidUrl();
- Assert.assertTrue(mFakeServer.didAttemptLoadInvalidUrl());
+ assertTrue(mFakeServer.didAttemptLoadInvalidUrl());
// we should not automatically issue a new request.
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Fake a navigation error if offline.
// When connected to the Internet this error may already have happened due to actually
@@ -1341,13 +1314,12 @@
// Once the bar opens, we make a new request at normal priority.
tapPeekingBarToExpandAndAssert();
waitForNormalPriorityUrlLoaded();
- Assert.assertEquals(2, mFakeServer.getLoadedUrlCount());
+ assertEquals(2, mFakeServer.getLoadedUrlCount());
}
/**
* Tests a simple Tap with disable-preload set.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapDisablePreload() throws InterruptedException, TimeoutException {
@@ -1363,12 +1335,11 @@
/**
* Tests that long-press selects text, and a subsequent tap will unselect text.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testLongPressGestureSelects() throws InterruptedException, TimeoutException {
longPressNode("intelligence");
- Assert.assertEquals("Intelligence", getSelectedText());
+ assertEquals("Intelligence", getSelectedText());
fakeResponse(false, 200, "Intelligence", "Intelligence", "alternate-term", false);
assertContainsParameters("Intelligence", "alternate-term");
waitForPanelToPeek();
@@ -1376,39 +1347,37 @@
clickNode("question-mark");
waitForGestureProcessing();
waitForPanelToCloseAndSelectionEmpty();
- Assert.assertTrue(TextUtils.isEmpty(getSelectedText()));
+ assertTrue(TextUtils.isEmpty(getSelectedText()));
assertLoadedNoUrl();
}
/**
* Tests that a Tap gesture selects the expected text.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapGestureSelects() throws InterruptedException, TimeoutException {
clickWordNode("intelligence");
- Assert.assertEquals("Intelligence", getSelectedText());
+ assertEquals("Intelligence", getSelectedText());
fakeResponse(false, 200, "Intelligence", "Intelligence", "alternate-term", false);
assertContainsParameters("Intelligence", "alternate-term");
waitForPanelToPeek();
assertLoadedLowPriorityUrl();
clickNode("question-mark");
waitForPanelToClose();
- Assert.assertNull(getSelectedText());
+ assertNull(getSelectedText());
}
/**
* Tests that a Tap gesture on a special character does not select or show the panel.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapGestureOnSpecialCharacterDoesntSelect()
throws InterruptedException, TimeoutException {
clickNode("question-mark");
waitForGestureProcessing();
- Assert.assertNull(getSelectedText());
+ assertNull(getSelectedText());
assertPanelClosedOrUndefined();
assertLoadedNoUrl();
}
@@ -1416,7 +1385,6 @@
/**
* Tests that a Tap gesture followed by scrolling clears the selection.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapGestureFollowedByScrollClearsSelection()
@@ -1428,13 +1396,12 @@
assertLoadedLowPriorityUrl();
scrollBasePage();
assertPanelClosedOrUndefined();
- Assert.assertTrue(TextUtils.isEmpty(mSelectionController.getSelectedText()));
+ assertTrue(TextUtils.isEmpty(mSelectionController.getSelectedText()));
}
/**
* Tests that a Tap gesture followed by tapping an invalid character doesn't select.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapGestureFollowedByInvalidTextTapCloses()
@@ -1443,7 +1410,7 @@
waitForPanelToPeek();
clickNode("question-mark");
waitForPanelToClose();
- Assert.assertNull(mSelectionController.getSelectedText());
+ assertNull(mSelectionController.getSelectedText());
}
/**
@@ -1452,7 +1419,6 @@
* @Feature({"ContextualSearch"})
* crbug.com/665633
*/
- @Test
@DisabledTest
public void testTapGestureFollowedByNonTextTap() throws InterruptedException, TimeoutException {
clickWordNode("states-far");
@@ -1464,32 +1430,30 @@
/**
* Tests that a Tap gesture far away toggles selecting text.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapGestureFarAwayTogglesSelecting()
throws InterruptedException, TimeoutException {
clickWordNode("states");
- Assert.assertEquals("States", getSelectedText());
+ assertEquals("States", getSelectedText());
waitForPanelToPeek();
clickNode("states-far");
waitForPanelToClose();
- Assert.assertNull(getSelectedText());
+ assertNull(getSelectedText());
clickNode("states-far");
waitForGestureProcessing();
waitForPanelToPeek();
- Assert.assertEquals("States", getSelectedText());
+ assertEquals("States", getSelectedText());
}
/**
* Tests that sequential Tap gestures nearby keep selecting.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapGesturesNearbyKeepSelecting() throws InterruptedException, TimeoutException {
clickWordNode("states");
- Assert.assertEquals("States", getSelectedText());
+ assertEquals("States", getSelectedText());
waitForPanelToPeek();
// Avoid issues with double-tap detection by ensuring sequential taps
// aren't treated as such. Double-tapping can also select words much as
@@ -1510,7 +1474,6 @@
/**
* Tests that a long-press gesture followed by scrolling does not clear the selection.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testLongPressGestureFollowedByScrollMaintainsSelection()
@@ -1519,14 +1482,13 @@
waitForPanelToPeek();
scrollBasePage();
assertPanelClosedOrUndefined();
- Assert.assertEquals("Intelligence", getSelectedText());
+ assertEquals("Intelligence", getSelectedText());
assertLoadedNoUrl();
}
/**
* Tests that a long-press gesture followed by a tap does not select.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testLongPressGestureFollowedByTapDoesntSelect()
@@ -1541,20 +1503,18 @@
/**
* Tests that the panel closes when its base page crashes.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testContextualSearchDismissedOnForegroundTabCrash()
throws InterruptedException, TimeoutException {
clickWordNode("states");
- Assert.assertEquals("States", getSelectedText());
+ assertEquals("States", getSelectedText());
waitForPanelToPeek();
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
- mActivityTestRule.getActivity().getActivityTab().simulateRendererKilledForTesting(
- true);
+ getActivity().getActivityTab().simulateRendererKilledForTesting(true);
}
});
@@ -1573,27 +1533,25 @@
/**
* Test the the panel does not close when some background tab crashes.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testContextualSearchNotDismissedOnBackgroundTabCrash()
throws InterruptedException, TimeoutException {
- ChromeTabUtils.newTabFromMenu(InstrumentationRegistry.getInstrumentation(),
- (ChromeTabbedActivity) mActivityTestRule.getActivity());
- final Tab tab2 =
- TabModelUtils.getCurrentTab(mActivityTestRule.getActivity().getCurrentTabModel());
+ ChromeTabUtils.newTabFromMenu(getInstrumentation(),
+ (ChromeTabbedActivity) getActivity());
+ final Tab tab2 = TabModelUtils.getCurrentTab(getActivity().getCurrentTabModel());
// TODO(donnd): consider using runOnUiThreadBlocking, won't need to waitForIdleSync?
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
- TabModelUtils.setIndex(mActivityTestRule.getActivity().getCurrentTabModel(), 0);
+ TabModelUtils.setIndex(getActivity().getCurrentTabModel(), 0);
}
});
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ getInstrumentation().waitForIdleSync();
clickWordNode("states");
- Assert.assertEquals("States", getSelectedText());
+ assertEquals("States", getSelectedText());
waitForPanelToPeek();
ThreadUtils.runOnUiThread(new Runnable() {
@@ -1610,7 +1568,6 @@
* Test that tapping on the Search Bar before having a resolved search term does not
* promote to a tab, and that after the resolution it does promote to a tab.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapSearchBarPromotesToTab() throws InterruptedException, TimeoutException {
@@ -1624,7 +1581,7 @@
tabCreatedHelper.notifyCalled();
}
};
- mActivityTestRule.getActivity().getTabModelSelector().addObserver(observer);
+ getActivity().getTabModelSelector().addObserver(observer);
// -------- TEST ---------
// Start a slow-resolve search and maximize the Panel.
@@ -1651,13 +1608,12 @@
tabCreatedHelper.waitForCallback(tabCreatedHelperCallCount);
// -------- CLEAN UP ---------
- mActivityTestRule.getActivity().getTabModelSelector().removeObserver(observer);
+ getActivity().getTabModelSelector().removeObserver(observer);
}
/**
* Tests that a Tap gesture on an element with an ARIA role does not trigger.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapOnRoleIgnored() throws InterruptedException, TimeoutException {
@@ -1670,7 +1626,6 @@
* Tests that a Tap gesture on an element with an ARIA attribute does not trigger.
* http://crbug.com/542874
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapOnARIAIgnored() throws InterruptedException, TimeoutException {
@@ -1682,7 +1637,6 @@
/**
* Tests that a Tap gesture on an element that is focusable does not trigger.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapOnFocusableIgnored() throws InterruptedException, TimeoutException {
@@ -1694,7 +1648,6 @@
/**
* Tests that taps can be resolve and prefetch limited for decided users.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -1724,7 +1677,6 @@
/**
* Tests that taps can be resolve-limited for undecided users.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -1757,7 +1709,6 @@
* Tests expanding the panel before the search term has resolved, verifies that nothing
* loads until the resolve completes and that it's now a normal priority URL.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testExpandBeforeSearchTermResolution()
@@ -1781,7 +1732,6 @@
* Tests that an error from the Search Term Resolution request causes a fallback to a
* search request for the literal selection.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testSearchTermResolutionError() throws InterruptedException, TimeoutException {
@@ -1800,7 +1750,6 @@
/**
* Tests that HTTPS does not resolve in the opt-out model before the user accepts.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testHttpsBeforeAcceptForOptOut() throws InterruptedException, TimeoutException {
@@ -1815,7 +1764,6 @@
/**
* Tests that HTTPS does resolve in the opt-out model after the user accepts.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testHttpsAfterAcceptForOptOut() throws InterruptedException, TimeoutException {
@@ -1828,7 +1776,6 @@
/**
* Tests that HTTP does resolve in the opt-out model before the user accepts.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testHttpBeforeAcceptForOptOut() throws InterruptedException, TimeoutException {
@@ -1840,7 +1787,6 @@
/**
* Tests that HTTP does resolve in the opt-out model after the user accepts.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testHttpAfterAcceptForOptOut() throws InterruptedException, TimeoutException {
@@ -1868,9 +1814,7 @@
Criteria.equals(isVisible, new Callable<Boolean>() {
@Override
public Boolean call() {
- return mActivityTestRule.getActivity()
- .getAppMenuHandler()
- .isAppMenuShowing();
+ return getActivity().getAppMenuHandler().isAppMenuShowing();
}
}));
}
@@ -1878,7 +1822,6 @@
/**
* Tests that the App Menu gets suppressed when Search Panel is expanded.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -1899,7 +1842,6 @@
/**
* Tests that the App Menu gets suppressed when Search Panel is maximized.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testAppMenuSuppressedWhenMaximized() throws InterruptedException, TimeoutException {
@@ -1926,7 +1868,6 @@
* the user has never ever opened the panel. Once the panel is opened, this limiting-feature
* is permanently disabled.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testPromoTapCount() throws InterruptedException, TimeoutException {
@@ -1971,7 +1912,6 @@
/**
* Tests the promo open counter.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -1981,26 +1921,25 @@
// A simple click / resolve / prefetch sequence without open should not change the counter.
clickToTriggerPrefetch();
- Assert.assertEquals(0, mPolicy.getPromoOpenCount());
+ assertEquals(0, mPolicy.getPromoOpenCount());
// An open should count.
clickToExpandAndClosePanel();
- Assert.assertEquals(1, mPolicy.getPromoOpenCount());
+ assertEquals(1, mPolicy.getPromoOpenCount());
// Another open should count.
clickToExpandAndClosePanel();
- Assert.assertEquals(2, mPolicy.getPromoOpenCount());
+ assertEquals(2, mPolicy.getPromoOpenCount());
// Once the user has decided, we should stop counting.
mPolicy.overrideDecidedStateForTesting(true);
clickToExpandAndClosePanel();
- Assert.assertEquals(2, mPolicy.getPromoOpenCount());
+ assertEquals(2, mPolicy.getPromoOpenCount());
}
/**
* Tests the promo open counter.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -2010,7 +1949,7 @@
// An open should not count for decided users.
clickToExpandAndClosePanel();
- Assert.assertEquals(0, mPolicy.getPromoOpenCount());
+ assertEquals(0, mPolicy.getPromoOpenCount());
}
// --------------------------------------------------------------------------------------------
@@ -2021,22 +1960,21 @@
* @SmallTest
* @Feature({"ContextualSearch"})
*/
- @Test
@FlakyTest
public void testTapCount() throws InterruptedException, TimeoutException {
- Assert.assertEquals(0, mPolicy.getTapCount());
+ assertEquals(0, mPolicy.getTapCount());
// A simple Tap should change the counter.
clickToTriggerPrefetch();
- Assert.assertEquals(1, mPolicy.getTapCount());
+ assertEquals(1, mPolicy.getTapCount());
// Another Tap should increase the counter.
clickToTriggerPrefetch();
- Assert.assertEquals(2, mPolicy.getTapCount());
+ assertEquals(2, mPolicy.getTapCount());
// An open should reset the counter.
clickToExpandAndClosePanel();
- Assert.assertEquals(0, mPolicy.getTapCount());
+ assertEquals(0, mPolicy.getTapCount());
}
// --------------------------------------------------------------------------------------------
@@ -2058,7 +1996,6 @@
* Tests that ContextualSearchObserver gets notified when user brings up contextual search
* panel via long press and then dismisses the panel by tapping on the base page.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -2067,17 +2004,16 @@
TestContextualSearchObserver observer = new TestContextualSearchObserver();
mManager.addObserver(observer);
longPressNode("states");
- Assert.assertEquals(0, observer.hideCount);
+ assertEquals(0, observer.hideCount);
tapBasePageToClosePanel();
- Assert.assertEquals(1, observer.hideCount);
+ assertEquals(1, observer.hideCount);
}
/**
* Tests that ContextualSearchObserver gets notified when user brings up contextual search
* panel via tap and then dismisses the panel by tapping on the base page.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -2085,10 +2021,10 @@
TestContextualSearchObserver observer = new TestContextualSearchObserver();
mManager.addObserver(observer);
clickWordNode("states");
- Assert.assertEquals(0, observer.hideCount);
+ assertEquals(0, observer.hideCount);
tapBasePageToClosePanel();
- Assert.assertEquals(1, observer.hideCount);
+ assertEquals(1, observer.hideCount);
}
/**
@@ -2101,9 +2037,7 @@
CriteriaHelper.pollUiThread(Criteria.equals(visible, new Callable<Boolean>() {
@Override
public Boolean call() {
- return mActivityTestRule.getActivity()
- .getActivityTab()
- .getContentViewCore()
+ return getActivity().getActivityTab().getContentViewCore()
.isSelectActionBarShowing();
}
}));
@@ -2113,7 +2047,6 @@
* Tests that ContextualSearchObserver gets notified when user brings up contextual search
* panel via long press and then dismisses the panel by tapping copy (hide select action mode).
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testNotifyObserverHideOnClearSelectionAfterTap()
@@ -2121,11 +2054,10 @@
TestContextualSearchObserver observer = new TestContextualSearchObserver();
mManager.addObserver(observer);
longPressNode("states");
- Assert.assertEquals(0, observer.hideCount);
+ assertEquals(0, observer.hideCount);
// Dismiss select action mode.
- final ContentViewCore contentViewCore =
- mActivityTestRule.getActivity().getActivityTab().getContentViewCore();
+ final ContentViewCore contentViewCore = getActivity().getActivityTab().getContentViewCore();
assertWaitForSelectActionBarVisible(true);
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
@@ -2136,7 +2068,7 @@
assertWaitForSelectActionBarVisible(false);
waitForPanelToClose();
- Assert.assertEquals(1, observer.hideCount);
+ assertEquals(1, observer.hideCount);
}
/**
@@ -2144,7 +2076,6 @@
* modified after the user has taken an action to explicitly dismiss the panel. Also tests
* that the panel reappears when a new selection is made.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testPreventHandlingCurrentSelectionModification()
@@ -2153,7 +2084,7 @@
// Dismiss the Contextual Search panel.
closePanel();
- Assert.assertEquals("Search", getSelectedText());
+ assertEquals("Search", getSelectedText());
// Simulate a selection change event and assert that the panel has not reappeared.
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@@ -2177,7 +2108,6 @@
* We've had reliability problems with a sequence of simple taps, due to async dissolving
* of selection bounds, so this helps prevent a regression with that.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapALot() throws InterruptedException, TimeoutException {
@@ -2194,37 +2124,36 @@
* Tests ContextualSearchManager#shouldInterceptNavigation for a case that an external
* navigation has a user gesture.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testExternalNavigationWithUserGesture() {
final ExternalNavigationHandler externalNavHandler =
- new ExternalNavigationHandler(mActivityTestRule.getActivity().getActivityTab());
+ new ExternalNavigationHandler(getActivity().getActivityTab());
final NavigationParams navigationParams = new NavigationParams(
"intent://test/#Intent;scheme=test;package=com.chrome.test;end", "",
false /* isPost */, true /* hasUserGesture */, PageTransition.LINK,
false /* isRedirect */, true /* isExternalProtocol */, true /* isMainFrame */,
false /* hasUserGestureCarryover */);
- InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
+ getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
- Assert.assertFalse(mManager.getOverlayContentDelegate().shouldInterceptNavigation(
- externalNavHandler, navigationParams));
+ assertFalse(
+ mManager.getOverlayContentDelegate().shouldInterceptNavigation(
+ externalNavHandler, navigationParams));
}
});
- Assert.assertEquals(1, mActivityMonitor.getHits());
+ assertEquals(1, mActivityMonitor.getHits());
}
/**
* Tests ContextualSearchManager#shouldInterceptNavigation for a case that an initial
* navigation has a user gesture but the redirected external navigation doesn't.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testRedirectedExternalNavigationWithUserGesture() {
final ExternalNavigationHandler externalNavHandler =
- new ExternalNavigationHandler(mActivityTestRule.getActivity().getActivityTab());
+ new ExternalNavigationHandler(getActivity().getActivityTab());
final NavigationParams initialNavigationParams = new NavigationParams("http://test.com", "",
false /* isPost */, true /* hasUserGesture */, PageTransition.LINK,
@@ -2236,45 +2165,44 @@
true /* isRedirect */, true /* isExternalProtocol */, true /* isMainFrame */,
false /* hasUserGestureCarryover */);
- InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
+ getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
OverlayContentDelegate delegate = mManager.getOverlayContentDelegate();
- Assert.assertTrue(delegate.shouldInterceptNavigation(
+ assertTrue(delegate.shouldInterceptNavigation(
externalNavHandler, initialNavigationParams));
- Assert.assertFalse(delegate.shouldInterceptNavigation(
+ assertFalse(delegate.shouldInterceptNavigation(
externalNavHandler, redirectedNavigationParams));
}
});
- Assert.assertEquals(1, mActivityMonitor.getHits());
+ assertEquals(1, mActivityMonitor.getHits());
}
/**
* Tests ContextualSearchManager#shouldInterceptNavigation for a case that an external
* navigation doesn't have a user gesture.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testExternalNavigationWithoutUserGesture() {
final ExternalNavigationHandler externalNavHandler =
- new ExternalNavigationHandler(mActivityTestRule.getActivity().getActivityTab());
+ new ExternalNavigationHandler(getActivity().getActivityTab());
final NavigationParams navigationParams = new NavigationParams(
"intent://test/#Intent;scheme=test;package=com.chrome.test;end", "",
false /* isPost */, false /* hasUserGesture */, PageTransition.LINK,
false /* isRedirect */, true /* isExternalProtocol */, true /* isMainFrame */,
false /* hasUserGestureCarryover */);
- InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
+ getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
- Assert.assertFalse(mManager.getOverlayContentDelegate().shouldInterceptNavigation(
- externalNavHandler, navigationParams));
+ assertFalse(
+ mManager.getOverlayContentDelegate().shouldInterceptNavigation(
+ externalNavHandler, navigationParams));
}
});
- Assert.assertEquals(0, mActivityMonitor.getHits());
- }
-
- @Test
+ assertEquals(0, mActivityMonitor.getHits());
+ }
+
@SmallTest
@Feature({"ContextualSearch"})
public void testSelectionExpansionOnSearchTermResolution()
@@ -2291,7 +2219,6 @@
/**
* Tests that long-press triggers the Peek Promo, and expanding the Panel dismisses it.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -2302,21 +2229,21 @@
// Must be in undecided state in order to trigger the Peek Promo.
mPolicy.overrideDecidedStateForTesting(false);
// Must have never opened the Panel in order to trigger the Peek Promo.
- Assert.assertEquals(0, mPolicy.getPromoOpenCount());
+ assertEquals(0, mPolicy.getPromoOpenCount());
// Long press and make sure the Promo shows.
longPressNode("intelligence");
waitForPanelToPeek();
- Assert.assertTrue(mPanel.isPeekPromoVisible());
+ assertTrue(mPanel.isPeekPromoVisible());
// After expanding the Panel the Promo should be invisible.
flingPanelUp();
waitForPanelToExpand();
- Assert.assertFalse(mPanel.isPeekPromoVisible());
+ assertFalse(mPanel.isPeekPromoVisible());
// After closing the Panel the Promo should still be invisible.
tapBasePageToClosePanel();
- Assert.assertFalse(mPanel.isPeekPromoVisible());
+ assertFalse(mPanel.isPeekPromoVisible());
// Click elsewhere to clear the selection.
clickNode("question-mark");
@@ -2325,7 +2252,7 @@
// Now that the Panel was opened at least once, the Promo should not show again.
longPressNode("intelligence");
waitForPanelToPeek();
- Assert.assertFalse(mPanel.isPeekPromoVisible());
+ assertFalse(mPanel.isPeekPromoVisible());
}
//============================================================================================
@@ -2335,7 +2262,6 @@
/**
* Tests that tap followed by expand makes Content visible.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -2357,7 +2283,6 @@
* Tests that long press followed by expand creates Content and makes it visible.
*
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -2380,7 +2305,6 @@
/**
* Tests swiping panel up and down after a tap search will only load the Content once.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -2389,34 +2313,33 @@
// Simulate a tap and make sure Content is not visible.
simulateTapSearch("search");
assertContentViewCoreCreatedButNeverMadeVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Expanding the Panel should make the Content visible.
tapPeekingBarToExpandAndAssert();
assertContentViewCoreVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Swiping the Panel down should not change the visibility or load content again.
swipePanelDown();
waitForPanelToPeek();
assertContentViewCoreVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Expanding the Panel should not change the visibility or load content again.
tapPeekingBarToExpandAndAssert();
assertContentViewCoreVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Closing the Panel should destroy the Content.
tapBasePageToClosePanel();
assertNoContentViewCore();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
}
/**
* Tests swiping panel up and down after a long press search will only load the Content once.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
@@ -2431,36 +2354,35 @@
tapPeekingBarToExpandAndAssert();
assertContentViewCoreCreated();
assertContentViewCoreVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Swiping the Panel down should not change the visibility or load content again.
swipePanelDown();
waitForPanelToPeek();
assertContentViewCoreVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Expanding the Panel should not change the visibility or load content again.
tapPeekingBarToExpandAndAssert();
assertContentViewCoreVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Closing the Panel should destroy the Content.
tapBasePageToClosePanel();
assertNoContentViewCore();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
}
/**
* Tests that chained tap searches create new Content.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testChainedSearchCreatesNewContent() throws InterruptedException, TimeoutException {
// Simulate a tap and make sure Content is not visible.
simulateTapSearch("search");
assertContentViewCoreCreatedButNeverMadeVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
ContentViewCore cvc1 = getPanelContentViewCore();
waitToPreventDoubleTapRecognition();
@@ -2468,29 +2390,28 @@
// Simulate a new tap and make sure a new Content is created.
simulateTapSearch("term");
assertContentViewCoreCreatedButNeverMadeVisible();
- Assert.assertEquals(2, mFakeServer.getLoadedUrlCount());
+ assertEquals(2, mFakeServer.getLoadedUrlCount());
ContentViewCore cvc2 = getPanelContentViewCore();
- Assert.assertNotSame(cvc1, cvc2);
+ assertNotSame(cvc1, cvc2);
waitToPreventDoubleTapRecognition();
// Simulate a new tap and make sure a new Content is created.
simulateTapSearch("resolution");
assertContentViewCoreCreatedButNeverMadeVisible();
- Assert.assertEquals(3, mFakeServer.getLoadedUrlCount());
+ assertEquals(3, mFakeServer.getLoadedUrlCount());
ContentViewCore cvc3 = getPanelContentViewCore();
- Assert.assertNotSame(cvc2, cvc3);
+ assertNotSame(cvc2, cvc3);
// Closing the Panel should destroy the Content.
closePanel();
assertNoContentViewCore();
- Assert.assertEquals(3, mFakeServer.getLoadedUrlCount());
+ assertEquals(3, mFakeServer.getLoadedUrlCount());
}
/**
* Tests that chained searches load correctly.
*/
- @Test
@DisabledTest(message = "crbug.com/551711")
@SmallTest
@Feature({"ContextualSearch"})
@@ -2500,19 +2421,19 @@
// Simulate a tap and make sure Content is not visible.
simulateTapSearch("search");
assertContentViewCoreCreatedButNeverMadeVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
ContentViewCore cvc1 = getPanelContentViewCore();
// Expanding the Panel should make the Content visible.
tapPeekingBarToExpandAndAssert();
assertContentViewCoreVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Swiping the Panel down should not change the visibility or load content again.
swipePanelDown();
waitForPanelToPeek();
assertContentViewCoreVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
waitToPreventDoubleTapRecognition();
@@ -2523,28 +2444,27 @@
tapPeekingBarToExpandAndAssert();
assertContentViewCoreCreated();
assertContentViewCoreVisible();
- Assert.assertEquals(2, mFakeServer.getLoadedUrlCount());
+ assertEquals(2, mFakeServer.getLoadedUrlCount());
assertLoadedSearchTermMatches("Resolution");
ContentViewCore cvc2 = getPanelContentViewCore();
- Assert.assertNotSame(cvc1, cvc2);
+ assertNotSame(cvc1, cvc2);
// Closing the Panel should destroy the Content.
tapBasePageToClosePanel();
assertNoContentViewCore();
- Assert.assertEquals(2, mFakeServer.getLoadedUrlCount());
+ assertEquals(2, mFakeServer.getLoadedUrlCount());
}
/**
* Tests that chained searches make Content visible when opening the Panel.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testChainedSearchContentVisibility() throws InterruptedException, TimeoutException {
// Simulate a tap and make sure Content is not visible.
simulateTapSearch("search");
assertContentViewCoreCreatedButNeverMadeVisible();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
ContentViewCore cvc1 = getPanelContentViewCore();
waitToPreventDoubleTapRecognition();
@@ -2552,16 +2472,16 @@
// Now simulate a long press, leaving the Panel peeking.
simulateLongPressSearch("resolution");
assertNeverCalledContentViewCoreOnShow();
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
// Expanding the Panel should load and display the new search.
tapPeekingBarToExpandAndAssert();
assertContentViewCoreCreated();
assertContentViewCoreVisible();
- Assert.assertEquals(2, mFakeServer.getLoadedUrlCount());
+ assertEquals(2, mFakeServer.getLoadedUrlCount());
assertLoadedSearchTermMatches("Resolution");
ContentViewCore cvc2 = getPanelContentViewCore();
- Assert.assertNotSame(cvc1, cvc2);
+ assertNotSame(cvc1, cvc2);
}
//============================================================================================
@@ -2571,33 +2491,31 @@
/**
* Tests that a tap followed by closing the Panel removes the loaded URL from history.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapCloseRemovedFromHistory() throws InterruptedException, TimeoutException {
// Simulate a tap and make sure a URL was loaded.
simulateTapSearch("search");
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
String url = mFakeServer.getLoadedUrl();
// Close the Panel without seeing the Content.
tapBasePageToClosePanel();
// Now check that the URL has been removed from history.
- Assert.assertTrue(mFakeServer.hasRemovedUrl(url));
+ assertTrue(mFakeServer.hasRemovedUrl(url));
}
/**
* Tests that a tap followed by opening the Panel does not remove the loaded URL from history.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
public void testTapExpandNotRemovedFromHistory() throws InterruptedException, TimeoutException {
// Simulate a tap and make sure a URL was loaded.
simulateTapSearch("search");
- Assert.assertEquals(1, mFakeServer.getLoadedUrlCount());
+ assertEquals(1, mFakeServer.getLoadedUrlCount());
String url = mFakeServer.getLoadedUrl();
// Expand Panel so that the Content becomes visible.
@@ -2607,43 +2525,42 @@
tapBasePageToClosePanel();
// Now check that the URL has not been removed from history, since the Content was seen.
- Assert.assertFalse(mFakeServer.hasRemovedUrl(url));
+ assertFalse(mFakeServer.hasRemovedUrl(url));
}
/**
* Tests that chained searches without opening the Panel removes all loaded URLs from history.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testChainedTapsRemovedFromHistory() throws InterruptedException, TimeoutException {
// Simulate a tap and make sure a URL was loaded.
simulateTapSearch("search");
String url1 = mFakeServer.getLoadedUrl();
- Assert.assertNotNull(url1);
+ assertNotNull(url1);
waitToPreventDoubleTapRecognition();
// Simulate another tap and make sure another URL was loaded.
simulateTapSearch("term");
String url2 = mFakeServer.getLoadedUrl();
- Assert.assertNotSame(url1, url2);
+ assertNotSame(url1, url2);
waitToPreventDoubleTapRecognition();
// Simulate another tap and make sure another URL was loaded.
simulateTapSearch("resolution");
String url3 = mFakeServer.getLoadedUrl();
- Assert.assertNotSame(url2, url3);
+ assertNotSame(url2, url3);
// Close the Panel without seeing any Content.
closePanel();
// Now check that all three URLs have been removed from history.
- Assert.assertEquals(3, mFakeServer.getLoadedUrlCount());
- Assert.assertTrue(mFakeServer.hasRemovedUrl(url1));
- Assert.assertTrue(mFakeServer.hasRemovedUrl(url2));
- Assert.assertTrue(mFakeServer.hasRemovedUrl(url3));
+ assertEquals(3, mFakeServer.getLoadedUrlCount());
+ assertTrue(mFakeServer.hasRemovedUrl(url1));
+ assertTrue(mFakeServer.hasRemovedUrl(url2));
+ assertTrue(mFakeServer.hasRemovedUrl(url3));
}
//============================================================================================
@@ -2653,7 +2570,6 @@
/**
* Tests that a simple Tap with language determination triggers translation.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapWithLanguage() throws InterruptedException, TimeoutException {
@@ -2661,7 +2577,7 @@
simulateTapSearch("german");
// Make sure we tried to trigger translate.
- Assert.assertTrue("Translation was not forced with the current request URL: "
+ assertTrue("Translation was not forced with the current request URL: "
+ mManager.getRequest().getSearchUrl(),
mManager.getRequest().isTranslationForced());
}
@@ -2669,7 +2585,6 @@
/**
* Tests translation with a simple Tap can be disabled.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@CommandLineFlags.Add(ContextualSearchFieldTrial.DISABLE_TRANSLATION + "=true")
@@ -2678,13 +2593,12 @@
simulateTapSearch("german");
// Make sure we did not try to trigger translate.
- Assert.assertFalse(mManager.getRequest().isTranslationForced());
+ assertFalse(mManager.getRequest().isTranslationForced());
}
/**
* Tests that a simple Tap without language determination does not trigger translation.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testTapWithoutLanguage() throws InterruptedException, TimeoutException {
@@ -2692,13 +2606,12 @@
simulateTapSearch("search");
// Make sure we did not try to trigger translate.
- Assert.assertFalse(mManager.getRequest().isTranslationForced());
+ assertFalse(mManager.getRequest().isTranslationForced());
}
/**
* Tests that a long-press does trigger translation.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testLongpressTranslates() throws InterruptedException, TimeoutException {
@@ -2706,13 +2619,12 @@
simulateLongPressSearch("search");
// Make sure we did try to trigger translate.
- Assert.assertTrue(mManager.getRequest().isTranslationForced());
+ assertTrue(mManager.getRequest().isTranslationForced());
}
/**
* Tests that a long-press does NOT trigger translation when disabled.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@CommandLineFlags.Add(ContextualSearchFieldTrial.DISABLE_TRANSLATION + "=true")
@@ -2722,7 +2634,7 @@
simulateLongPressSearch("search");
// Make sure we did not try to trigger translate.
- Assert.assertFalse(mManager.getRequest().isTranslationForced());
+ assertFalse(mManager.getRequest().isTranslationForced());
}
/**
@@ -2730,25 +2642,22 @@
* peeks the panel, expanding the bar results in the bar ending at the correct spot in the page
* and tapping the base page closes the panel.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
public void testTapContentAndExpandPanelInFullscreen()
throws InterruptedException, TimeoutException {
// Toggle tab to fulllscreen.
- FullscreenTestUtils.togglePersistentFullscreenAndAssert(
- mActivityTestRule.getActivity().getActivityTab(), true,
- mActivityTestRule.getActivity());
+ FullscreenTestUtils.togglePersistentFullscreenAndAssert(getActivity().getActivityTab(),
+ true, getActivity());
// Simulate a tap and assert that the panel peeks.
simulateTapSearch("search");
// Expand the panel and assert that it ends up in the right place.
tapPeekingBarToExpandAndAssert();
- Assert.assertEquals(mManager.getContextualSearchPanel().getHeight(),
- mManager.getContextualSearchPanel().getPanelHeightFromState(PanelState.EXPANDED),
- 0);
+ assertEquals(mManager.getContextualSearchPanel().getHeight(),
+ mManager.getContextualSearchPanel().getPanelHeightFromState(PanelState.EXPANDED));
// Tap the base page and assert that the panel is closed.
tapBasePageToClosePanel();
@@ -2757,7 +2666,6 @@
/**
* Tests that the Contextual Search panel is dismissed when entering or exiting fullscreen.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testPanelDismissedOnToggleFullscreen()
@@ -2766,9 +2674,8 @@
simulateTapSearch("search");
// Toggle tab to fullscreen.
- Tab tab = mActivityTestRule.getActivity().getActivityTab();
- FullscreenTestUtils.togglePersistentFullscreenAndAssert(
- tab, true, mActivityTestRule.getActivity());
+ Tab tab = getActivity().getActivityTab();
+ FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, true, getActivity());
// Assert that the panel is closed.
waitForPanelToClose();
@@ -2777,8 +2684,7 @@
simulateTapSearch("search");
// Toggle tab to non-fullscreen.
- FullscreenTestUtils.togglePersistentFullscreenAndAssert(
- tab, false, mActivityTestRule.getActivity());
+ FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, false, getActivity());
// Assert that the panel is closed.
waitForPanelToClose();
@@ -2788,7 +2694,6 @@
* Tests that ContextualSearchImageControl correctly sets either the icon sprite or thumbnail
* as visible.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testImageControl() throws InterruptedException, TimeoutException {
@@ -2796,8 +2701,8 @@
final ContextualSearchImageControl imageControl = mPanel.getImageControl();
- Assert.assertFalse(imageControl.getThumbnailVisible());
- Assert.assertTrue(TextUtils.isEmpty(imageControl.getThumbnailUrl()));
+ assertFalse(imageControl.getThumbnailVisible());
+ assertTrue(TextUtils.isEmpty(imageControl.getThumbnailUrl()));
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
@@ -2807,8 +2712,8 @@
}
});
- Assert.assertTrue(imageControl.getThumbnailVisible());
- Assert.assertEquals(imageControl.getThumbnailUrl(), "http://someimageurl.com/image.png");
+ assertTrue(imageControl.getThumbnailVisible());
+ assertEquals(imageControl.getThumbnailUrl(), "http://someimageurl.com/image.png");
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
@@ -2817,8 +2722,8 @@
}
});
- Assert.assertFalse(imageControl.getThumbnailVisible());
- Assert.assertTrue(TextUtils.isEmpty(imageControl.getThumbnailUrl()));
+ assertFalse(imageControl.getThumbnailVisible());
+ assertTrue(TextUtils.isEmpty(imageControl.getThumbnailUrl()));
}
// TODO(twellington): Add an end-to-end integration test for fetching a thumbnail based on a
@@ -2827,7 +2732,6 @@
/**
* Tests that Contextual Search is fully disabled when offline.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
// NOTE: Remove the flag so we will run just this test with onLine detection enabled.
@@ -2853,7 +2757,6 @@
* Tests that the quick action caption is set correctly when one is available. Also tests that
* the caption gets changed when the panel is expanded and reset when the panel is closed.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testQuickActionCaptionAndImage() throws InterruptedException, TimeoutException {
@@ -2874,12 +2777,12 @@
ContextualSearchImageControl imageControl = mPanel.getImageControl();
// Check that the peeking bar is showing the quick action data.
- Assert.assertTrue(quickActionControl.hasQuickAction());
- Assert.assertTrue(barControl.getCaptionVisible());
- Assert.assertEquals(mActivityTestRule.getActivity().getResources().getString(
- R.string.contextual_search_quick_action_caption_phone),
+ assertTrue(quickActionControl.hasQuickAction());
+ assertTrue(barControl.getCaptionVisible());
+ assertEquals(getActivity().getResources().getString(
+ R.string.contextual_search_quick_action_caption_phone),
barControl.getCaptionText());
- Assert.assertEquals(1.f, imageControl.getCustomImageVisibilityPercentage(), 0);
+ assertEquals(1.f, imageControl.getCustomImageVisibilityPercentage());
// Expand the bar.
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@@ -2891,37 +2794,36 @@
waitForPanelToExpand();
// Check that the expanded bar is showing the correct image and caption.
- Assert.assertTrue(barControl.getCaptionVisible());
- Assert.assertEquals(mActivityTestRule.getActivity().getResources().getString(
- ContextualSearchCaptionControl.EXPANED_CAPTION_ID),
+ assertTrue(barControl.getCaptionVisible());
+ assertEquals(getActivity().getResources().getString(
+ ContextualSearchCaptionControl.EXPANED_CAPTION_ID),
barControl.getCaptionText());
- Assert.assertEquals(0.f, imageControl.getCustomImageVisibilityPercentage(), 0);
+ assertEquals(0.f, imageControl.getCustomImageVisibilityPercentage());
// Go back to peeking.
swipePanelDown();
waitForPanelToPeek();
// Assert that the quick action data is showing.
- Assert.assertTrue(barControl.getCaptionVisible());
- Assert.assertEquals(mActivityTestRule.getActivity().getResources().getString(
- R.string.contextual_search_quick_action_caption_phone),
+ assertTrue(barControl.getCaptionVisible());
+ assertEquals(getActivity().getResources().getString(
+ R.string.contextual_search_quick_action_caption_phone),
barControl.getCaptionText());
- Assert.assertEquals(1.f, imageControl.getCustomImageVisibilityPercentage(), 0);
+ assertEquals(1.f, imageControl.getCustomImageVisibilityPercentage());
}
/**
* Tests that an intent is sent when the bar is tapped and a quick action is available.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testQuickActionIntent() throws InterruptedException, TimeoutException {
// Add a new filter to the activity monitor that matches the intent that should be fired.
IntentFilter quickActionFilter = new IntentFilter(Intent.ACTION_VIEW);
quickActionFilter.addDataScheme("tel");
- mActivityMonitor =
- InstrumentationRegistry.getInstrumentation().addMonitor(quickActionFilter,
- new Instrumentation.ActivityResult(Activity.RESULT_OK, null), true);
+ mActivityMonitor = getInstrumentation().addMonitor(
+ quickActionFilter, new Instrumentation.ActivityResult(Activity.RESULT_OK, null),
+ true);
// Simulate a tap to show the Bar, then set the quick action data.
simulateTapSearch("search");
@@ -2937,14 +2839,13 @@
clickPanelBar();
// Assert that an intent was fired.
- Assert.assertEquals(1, mActivityMonitor.getHits());
+ assertEquals(1, mActivityMonitor.getHits());
}
/**
* Tests that the current tab is navigated to the quick action URI for
* QuickActionCategory#WEBSITE.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testQuickActionUrl() throws InterruptedException, TimeoutException {
@@ -2963,14 +2864,12 @@
clickPanelBar();
// Assert that the URL was loaded.
- ChromeTabUtils.waitForTabPageLoaded(
- mActivityTestRule.getActivity().getActivityTab(), testUrl);
+ ChromeTabUtils.waitForTabPageLoaded(getActivity().getActivityTab(), testUrl);
}
/**
* Tests accessibility mode: Tap and Long-press don't activate CS.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testAccesibilityMode() throws InterruptedException, TimeoutException {
@@ -2990,7 +2889,6 @@
/**
* Tests that the Manager cycles through all the expected Internal States on Tap that Resolves.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testAllInternalStatesVisitedResolvingTap()
@@ -3003,20 +2901,17 @@
// Simulate a tap that resolves to show the Bar.
simulateTapSearch("search");
- Assert.assertEquals(
- InternalState.SHOWING_TAP_SEARCH, internalStateControllerWrapper.getState());
-
- Assert.assertEquals(internalStateControllerWrapper.getStartedStates(),
+ assertEquals(InternalState.SHOWING_TAP_SEARCH, internalStateControllerWrapper.getState());
+
+ assertEquals(internalStateControllerWrapper.getStartedStates(),
internalStateControllerWrapper.getFinishedStates());
- Assert.assertEquals(
- ContextualSearchInternalStateControllerWrapper.EXPECTED_TAP_RESOLVE_SEQUENCE,
+ assertEquals(ContextualSearchInternalStateControllerWrapper.EXPECTED_TAP_RESOLVE_SEQUENCE,
internalStateControllerWrapper.getFinishedStates());
}
/**
* Tests that the Manager cycles through all the expected Internal States on a Long-press.
*/
- @Test
@SmallTest
@Feature({"ContextualSearch"})
public void testAllInternalStatesVisitedLongpress()
@@ -3030,10 +2925,9 @@
// Simulate a Long-press to show the Bar.
simulateLongPressSearch("search");
- Assert.assertEquals(internalStateControllerWrapper.getStartedStates(),
+ assertEquals(internalStateControllerWrapper.getStartedStates(),
internalStateControllerWrapper.getFinishedStates());
- Assert.assertEquals(
- ContextualSearchInternalStateControllerWrapper.EXPECTED_LONGPRESS_SEQUENCE,
+ assertEquals(ContextualSearchInternalStateControllerWrapper.EXPECTED_LONGPRESS_SEQUENCE,
internalStateControllerWrapper.getFinishedStates());
}
}

Powered by Google App Engine
This is Rietveld 408576698