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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/ContentViewPopupZoomerTest.java

Issue 2708243004: Auto convert content shell tests to JUnit4 (Closed)
Patch Set: rebase Created 3 years, 9 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: content/public/android/javatests/src/org/chromium/content/browser/ContentViewPopupZoomerTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewPopupZoomerTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewPopupZoomerTest.java
index a2ad38245bd5321e5ec14d63dfe7d7204093f6a5..a2cef5cc1e5faceb21ce94606f4845aae5e29beb 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewPopupZoomerTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewPopupZoomerTest.java
@@ -4,26 +4,36 @@
package org.chromium.content.browser;
+import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.DOMUtils;
-import org.chromium.content_shell_apk.ContentShellTestBase;
+import org.chromium.content_shell_apk.ContentShellActivityTestRule;
import java.util.concurrent.TimeoutException;
/**
* Class which provides test coverage for Popup Zoomer.
*/
+@RunWith(BaseJUnit4ClassRunner.class)
@RetryOnFailure
-public class ContentViewPopupZoomerTest extends ContentShellTestBase {
+public class ContentViewPopupZoomerTest {
+ @Rule
+ public ContentShellActivityTestRule mActivityTestRule = new ContentShellActivityTestRule();
+
private static PopupZoomer findPopupZoomer(ViewGroup view) {
assert view != null;
for (int i = 0; i < view.getChildCount(); i++) {
@@ -85,13 +95,14 @@ public class ContentViewPopupZoomerTest extends ContentShellTestBase {
/**
* Tests that shows a zoomer popup and makes sure it has valid dimensions.
*/
+ @Test
@MediumTest
@Feature({"Browser"})
public void testPopupZoomerShowsUp() throws InterruptedException, TimeoutException {
- launchContentShellWithUrl(generateTestUrl(100, 15, "clickme"));
- waitForActiveShellToBeDoneLoading();
+ mActivityTestRule.launchContentShellWithUrl(generateTestUrl(100, 15, "clickme"));
+ mActivityTestRule.waitForActiveShellToBeDoneLoading();
- final ContentViewCore viewCore = getContentViewCore();
+ final ContentViewCore viewCore = mActivityTestRule.getContentViewCore();
final ViewGroup view = viewCore.getContainerView();
// The popup should be hidden before the click.
@@ -108,20 +119,21 @@ public class ContentViewPopupZoomerTest extends ContentShellTestBase {
/**
* Tests Popup zoomer hides when device back key is pressed.
*/
+ @Test
@MediumTest
@Feature({"Browser"})
@RetryOnFailure
public void testBackKeyDismissesPopupZoomer() throws InterruptedException, TimeoutException {
- launchContentShellWithUrl(generateTestUrl(100, 15, "clickme"));
- waitForActiveShellToBeDoneLoading();
+ mActivityTestRule.launchContentShellWithUrl(generateTestUrl(100, 15, "clickme"));
+ mActivityTestRule.waitForActiveShellToBeDoneLoading();
- final ContentViewCore viewCore = getContentViewCore();
+ final ContentViewCore viewCore = mActivityTestRule.getContentViewCore();
final ViewGroup view = viewCore.getContainerView();
CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, false));
DOMUtils.clickNode(viewCore, "clickme");
CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, true));
- sendKeys(KeyEvent.KEYCODE_BACK);
+ InstrumentationRegistry.getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
// When device key is pressed, popup zoomer should hide if already showing.
CriteriaHelper.pollInstrumentationThread(new PopupShowingCriteria(view, false));
}

Powered by Google App Engine
This is Rietveld 408576698