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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryTest.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/autofill/AutofillKeyboardAccessoryTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryTest.java
index b8313e57918732ca8ea8682faf0e283b6f9c5298..be60094217da5db1ae4a1c03b055193bc6dd43fc 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryTest.java
@@ -9,11 +9,6 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
-
-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;
@@ -25,8 +20,7 @@
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
-import org.chromium.chrome.test.ChromeActivityTestRule;
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
@@ -42,16 +36,9 @@
/**
* Integration tests for autofill keyboard accessory.
*/
-@RunWith(ChromeJUnit4ClassRunner.class)
+@CommandLineFlags.Add({ChromeSwitches.ENABLE_AUTOFILL_KEYBOARD_ACCESSORY})
@RetryOnFailure
-@CommandLineFlags.Add({ChromeSwitches.ENABLE_AUTOFILL_KEYBOARD_ACCESSORY,
- ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
-public class AutofillKeyboardAccessoryTest {
- @Rule
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
- new ChromeActivityTestRule<>(ChromeActivity.class);
-
+public class AutofillKeyboardAccessoryTest extends ChromeActivityTestCaseBase<ChromeActivity> {
private final AtomicReference<ContentViewCore> mViewCoreRef =
new AtomicReference<ContentViewCore>();
private final AtomicReference<WebContents> mWebContentsRef = new AtomicReference<WebContents>();
@@ -59,10 +46,18 @@
private final AtomicReference<ViewGroup> mKeyboardAccessoryRef =
new AtomicReference<ViewGroup>();
+ public AutofillKeyboardAccessoryTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {}
+
private void loadTestPage(boolean isRtl) throws InterruptedException, ExecutionException,
TimeoutException {
- mActivityTestRule.startMainActivityWithURL(UrlUtils.encodeHtmlDataUri("<html"
- + (isRtl ? " dir=\"rtl\"" : "") + "><head>"
+ startMainActivityWithURL(UrlUtils.encodeHtmlDataUri("<html"
+ + (isRtl ? " dir=\"rtl\"" : "")
+ + "><head>"
+ "<meta name=\"viewport\""
+ "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\" /></head>"
+ "<body><form method=\"POST\">"
@@ -95,12 +90,11 @@
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- mViewCoreRef.set(mActivityTestRule.getActivity().getCurrentContentViewCore());
+ mViewCoreRef.set(getActivity().getCurrentContentViewCore());
mWebContentsRef.set(mViewCoreRef.get().getWebContents());
mContainerRef.set(mViewCoreRef.get().getContainerView());
- mKeyboardAccessoryRef.set(mActivityTestRule.getActivity()
- .getWindowAndroid()
- .getKeyboardAccessoryView());
+ mKeyboardAccessoryRef.set(
+ getActivity().getWindowAndroid().getKeyboardAccessoryView());
}
});
DOMUtils.waitForNonZeroNodeBounds(mWebContentsRef.get(), "fn");
@@ -109,49 +103,42 @@
/**
* Autofocused fields should not show a keyboard accessory.
*/
- @Test
- @MediumTest
- @Feature({"keyboard-accessory"})
- public void testAutofocusedFieldDoesNotShowKeyboardAccessory()
- throws InterruptedException, ExecutionException, TimeoutException {
+ @MediumTest
+ @Feature({"keyboard-accessory"})
+ public void testAutofocusedFieldDoesNotShowKeyboardAccessory() throws InterruptedException,
+ ExecutionException, TimeoutException {
loadTestPage(false);
- Assert.assertTrue("Keyboard accessory should be hidden.",
- ThreadUtils
- .runOnUiThreadBlocking(new Callable<Boolean>() {
- @Override
- public Boolean call() {
- return mKeyboardAccessoryRef.get().getVisibility() == View.GONE;
- }
- })
- .booleanValue());
+ assertTrue("Keyboard accessory should be hidden.",
+ ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return mKeyboardAccessoryRef.get().getVisibility() == View.GONE;
+ }
+ }).booleanValue());
}
/**
* Tapping on an input field should show a keyboard and its keyboard accessory.
*/
- @Test
- @MediumTest
- @Feature({"keyboard-accessory"})
- public void testTapInputFieldShowsKeyboardAccessory()
- throws ExecutionException, InterruptedException, TimeoutException {
+ @MediumTest
+ @Feature({"keyboard-accessory"})
+ public void testTapInputFieldShowsKeyboardAccessory() throws ExecutionException,
+ InterruptedException, TimeoutException {
loadTestPage(false);
DOMUtils.clickNode(mViewCoreRef.get(), "fn");
CriteriaHelper.pollUiThread(new Criteria("Keyboard should be showing.") {
@Override
public boolean isSatisfied() {
- return UiUtils.isKeyboardShowing(
- mActivityTestRule.getActivity(), mContainerRef.get());
- }
- });
- Assert.assertTrue("Keyboard accessory should be showing.",
- ThreadUtils
- .runOnUiThreadBlocking(new Callable<Boolean>() {
- @Override
- public Boolean call() {
- return mKeyboardAccessoryRef.get().getVisibility() == View.VISIBLE;
- }
- })
- .booleanValue());
+ return UiUtils.isKeyboardShowing(getActivity(), mContainerRef.get());
+ }
+ });
+ assertTrue("Keyboard accessory should be showing.",
+ ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return mKeyboardAccessoryRef.get().getVisibility() == View.VISIBLE;
+ }
+ }).booleanValue());
}
/**
@@ -161,17 +148,15 @@
@MediumTest
@Feature({"keyboard-accessory"})
*/
- @Test
@FlakyTest(message = "https://crbug.com/563640")
- public void testSwitchFieldsRescrollsKeyboardAccessory()
- throws ExecutionException, InterruptedException, TimeoutException {
+ public void testSwitchFieldsRescrollsKeyboardAccessory() throws ExecutionException,
+ InterruptedException, TimeoutException {
loadTestPage(false);
DOMUtils.clickNode(mViewCoreRef.get(), "fn");
CriteriaHelper.pollUiThread(new Criteria("Keyboard should be showing.") {
@Override
public boolean isSatisfied() {
- return UiUtils.isKeyboardShowing(
- mActivityTestRule.getActivity(), mContainerRef.get());
+ return UiUtils.isKeyboardShowing(getActivity(), mContainerRef.get());
}
});
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@@ -212,19 +197,17 @@
* RTL is only supported on Jelly Bean MR 1+.
* http://android-developers.blogspot.com/2013/03/native-rtl-support-in-android-42.html
*/
- @Test
@MediumTest
@Feature({"keyboard-accessory"})
@MinAndroidSdkLevel(Build.VERSION_CODES.JELLY_BEAN_MR1)
- public void testSwitchFieldsRescrollsKeyboardAccessoryRtl()
- throws ExecutionException, InterruptedException, TimeoutException {
+ public void testSwitchFieldsRescrollsKeyboardAccessoryRtl() throws ExecutionException,
+ InterruptedException, TimeoutException {
loadTestPage(true);
DOMUtils.clickNode(mViewCoreRef.get(), "fn");
CriteriaHelper.pollUiThread(new Criteria("Keyboard should be showing.") {
@Override
public boolean isSatisfied() {
- return UiUtils.isKeyboardShowing(
- mActivityTestRule.getActivity(), mContainerRef.get());
+ return UiUtils.isKeyboardShowing(getActivity(), mContainerRef.get());
}
});
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@@ -268,18 +251,16 @@
* Selecting a keyboard accessory suggestion should hide the keyboard and its keyboard
* accessory.
*/
- @Test
- @MediumTest
- @Feature({"keyboard-accessory"})
- public void testSelectSuggestionHidesKeyboardAccessory()
- throws ExecutionException, InterruptedException, TimeoutException {
+ @MediumTest
+ @Feature({"keyboard-accessory"})
+ public void testSelectSuggestionHidesKeyboardAccessory() throws ExecutionException,
+ InterruptedException, TimeoutException {
loadTestPage(false);
DOMUtils.clickNode(mViewCoreRef.get(), "fn");
CriteriaHelper.pollUiThread(new Criteria("Keyboard should be showing.") {
@Override
public boolean isSatisfied() {
- return UiUtils.isKeyboardShowing(
- mActivityTestRule.getActivity(), mContainerRef.get());
+ return UiUtils.isKeyboardShowing(getActivity(), mContainerRef.get());
}
});
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@@ -294,19 +275,16 @@
CriteriaHelper.pollUiThread(new Criteria("Keyboard should be hidden.") {
@Override
public boolean isSatisfied() {
- return !UiUtils.isKeyboardShowing(
- mActivityTestRule.getActivity(), mContainerRef.get());
- }
- });
- Assert.assertTrue("Keyboard accessory should be hidden.",
- ThreadUtils
- .runOnUiThreadBlocking(new Callable<Boolean>() {
- @Override
- public Boolean call() {
- return mKeyboardAccessoryRef.get().getVisibility() == View.GONE;
- }
- })
- .booleanValue());
+ return !UiUtils.isKeyboardShowing(getActivity(), mContainerRef.get());
+ }
+ });
+ assertTrue("Keyboard accessory should be hidden.",
+ ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return mKeyboardAccessoryRef.get().getVisibility() == View.GONE;
+ }
+ }).booleanValue());
}
private View getSuggestionAt(int index) {

Powered by Google App Engine
This is Rietveld 408576698