| Index: chrome/android/javatests/src/org/chromium/chrome/browser/UsbChooserDialogTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/UsbChooserDialogTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/UsbChooserDialogTest.java
|
| index df062e81f4475fdbaa221e6367d3e44159935790..3ded6e62b7145a35cfccba976a7527a7786835c5 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/UsbChooserDialogTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/UsbChooserDialogTest.java
|
| @@ -10,18 +10,10 @@
|
| import android.widget.Button;
|
| import android.widget.ListView;
|
|
|
| -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.RetryOnFailure;
|
| import org.chromium.chrome.R;
|
| -import org.chromium.chrome.test.ChromeActivityTestRule;
|
| -import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
| +import org.chromium.chrome.test.ChromeActivityTestCaseBase;
|
| import org.chromium.components.security_state.ConnectionSecurityLevel;
|
| import org.chromium.content.browser.test.util.Criteria;
|
| import org.chromium.content.browser.test.util.CriteriaHelper;
|
| @@ -33,20 +25,12 @@
|
| /**
|
| * Tests for the UsbChooserDialog class.
|
| */
|
| -@RunWith(ChromeJUnit4ClassRunner.class)
|
| @RetryOnFailure
|
| -@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
|
| - ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
|
| -public class UsbChooserDialogTest {
|
| +public class UsbChooserDialogTest extends ChromeActivityTestCaseBase<ChromeActivity> {
|
| /**
|
| * Works like the UsbChooserDialog class, but records calls to native methods instead of
|
| * calling back to C++.
|
| */
|
| -
|
| - @Rule
|
| - public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
|
| - new ChromeActivityTestRule<>(ChromeActivity.class);
|
| -
|
| static class UsbChooserDialogWithFakeNatives extends UsbChooserDialog {
|
| String mSelectedDeviceId = "";
|
|
|
| @@ -68,12 +52,21 @@
|
|
|
| private UsbChooserDialogWithFakeNatives mChooserDialog;
|
|
|
| + public UsbChooserDialogTest() {
|
| + super(ChromeActivity.class);
|
| + }
|
| +
|
| // ChromeActivityTestCaseBase:
|
|
|
| - @Before
|
| - public void setUp() throws Exception {
|
| - mActivityTestRule.startMainActivityOnBlankPage();
|
| + @Override
|
| + protected void setUp() throws Exception {
|
| + super.setUp();
|
| mChooserDialog = createDialog();
|
| + }
|
| +
|
| + @Override
|
| + public void startMainActivity() throws InterruptedException {
|
| + startMainActivityOnBlankPage();
|
| }
|
|
|
| private UsbChooserDialogWithFakeNatives createDialog() {
|
| @@ -83,7 +76,7 @@
|
| public UsbChooserDialogWithFakeNatives call() {
|
| UsbChooserDialogWithFakeNatives dialog =
|
| new UsbChooserDialogWithFakeNatives();
|
| - dialog.show(mActivityTestRule.getActivity(), "https://origin.example.com/",
|
| + dialog.show(getActivity(), "https://origin.example.com/",
|
| ConnectionSecurityLevel.SECURE);
|
| return dialog;
|
| }
|
| @@ -134,18 +127,17 @@
|
| "</?link2>", "").replaceAll("</?link>", "");
|
| }
|
|
|
| - @Test
|
| @LargeTest
|
| public void testCancel() {
|
| Dialog dialog = mChooserDialog.mItemChooserDialog.getDialogForTesting();
|
| - Assert.assertTrue(dialog.isShowing());
|
| + assertTrue(dialog.isShowing());
|
|
|
| final ListView items = (ListView) dialog.findViewById(R.id.items);
|
| final Button button = (Button) dialog.findViewById(R.id.positive);
|
|
|
| // The 'Connect' button should be disabled and the list view should be hidden.
|
| - Assert.assertFalse(button.isEnabled());
|
| - Assert.assertEquals(View.GONE, items.getVisibility());
|
| + assertFalse(button.isEnabled());
|
| + assertEquals(View.GONE, items.getVisibility());
|
|
|
| dialog.dismiss();
|
|
|
| @@ -157,7 +149,6 @@
|
| });
|
| }
|
|
|
| - @Test
|
| @LargeTest
|
| public void testSelectItem() throws InterruptedException {
|
| Dialog dialog = mChooserDialog.mItemChooserDialog.getDialogForTesting();
|
| @@ -183,14 +174,14 @@
|
| // After adding items to the dialog, the help message should be showing,
|
| // the 'Connect' button should still be disabled (since nothing's selected),
|
| // and the list view should show.
|
| - Assert.assertEquals(removeLinkTags(mActivityTestRule.getActivity().getString(
|
| - R.string.usb_chooser_dialog_footnote_text)),
|
| + assertEquals(removeLinkTags(getActivity().getString(
|
| + R.string.usb_chooser_dialog_footnote_text)),
|
| statusView.getText().toString());
|
| - Assert.assertFalse(button.isEnabled());
|
| - Assert.assertEquals(View.VISIBLE, items.getVisibility());
|
| + assertFalse(button.isEnabled());
|
| + assertEquals(View.VISIBLE, items.getVisibility());
|
|
|
| selectItem(mChooserDialog, position);
|
|
|
| - Assert.assertEquals("device_id_1", mChooserDialog.mSelectedDeviceId);
|
| + assertEquals("device_id_1", mChooserDialog.mSelectedDeviceId);
|
| }
|
| }
|
|
|