Index: chrome/android/javatests/src/org/chromium/chrome/browser/SelectFileDialogTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/SelectFileDialogTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/SelectFileDialogTest.java |
index fbe0293e3ce15eb1b393042572749f5b4d4dfedb..ac8125f0256c4bd63cf094e14d4afa8e1597feb8 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/SelectFileDialogTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/SelectFileDialogTest.java |
@@ -11,19 +11,11 @@ |
import android.provider.MediaStore; |
import android.support.test.filters.MediumTest; |
-import org.junit.Assert; |
-import org.junit.Before; |
-import org.junit.Rule; |
-import org.junit.Test; |
-import org.junit.runner.RunWith; |
- |
import org.chromium.base.ThreadUtils; |
-import org.chromium.base.test.util.CommandLineFlags; |
import org.chromium.base.test.util.Feature; |
import org.chromium.base.test.util.RetryOnFailure; |
import org.chromium.base.test.util.UrlUtils; |
-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; |
@@ -34,14 +26,7 @@ |
/** |
* Integration test for select file dialog used for <input type="file" /> |
*/ |
-@RunWith(ChromeJUnit4ClassRunner.class) |
-@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
-public class SelectFileDialogTest { |
- @Rule |
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = |
- new ChromeActivityTestRule<>(ChromeActivity.class); |
- |
+public class SelectFileDialogTest extends ChromeActivityTestCaseBase<ChromeActivity> { |
private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( |
"<html><head><meta name=\"viewport\"" |
+ "content=\"width=device-width, initial-scale=2.0, maximum-scale=2.0\" /></head>" |
@@ -92,29 +77,31 @@ |
private ContentViewCore mContentViewCore; |
private ActivityWindowAndroidForTest mActivityWindowAndroidForTest; |
- @Before |
+ public SelectFileDialogTest() { |
+ super(ChromeActivity.class); |
+ } |
+ |
+ @Override |
+ public void startMainActivity() throws InterruptedException { |
+ startMainActivityWithURL(DATA_URL); |
+ } |
+ |
+ @Override |
public void setUp() throws Exception { |
- mActivityTestRule.startMainActivityWithURL(DATA_URL); |
+ super.setUp(); |
- ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
- @Override |
- public void run() { |
- mActivityWindowAndroidForTest = |
- new ActivityWindowAndroidForTest(mActivityTestRule.getActivity()); |
- SelectFileDialog.setWindowAndroidForTests(mActivityWindowAndroidForTest); |
+ mActivityWindowAndroidForTest = new ActivityWindowAndroidForTest(getActivity()); |
+ SelectFileDialog.setWindowAndroidForTests(mActivityWindowAndroidForTest); |
- mContentViewCore = mActivityTestRule.getActivity().getCurrentContentViewCore(); |
- // TODO(aurimas) remove this wait once crbug.com/179511 is fixed. |
- mActivityTestRule.assertWaitForPageScaleFactorMatch(2); |
- } |
- }); |
+ mContentViewCore = getActivity().getCurrentContentViewCore(); |
+ // TODO(aurimas) remove this wait once crbug.com/179511 is fixed. |
+ assertWaitForPageScaleFactorMatch(2); |
DOMUtils.waitForNonZeroNodeBounds(mContentViewCore.getWebContents(), "input_file"); |
} |
/** |
* Tests that clicks on <input type="file" /> trigger intent calls to ActivityWindowAndroid. |
*/ |
- @Test |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) |
@MediumTest |
@Feature({"TextInput", "Main"}) |
@@ -123,67 +110,67 @@ |
{ |
DOMUtils.clickNode(mContentViewCore, "input_file"); |
CriteriaHelper.pollInstrumentationThread(new IntentSentCriteria()); |
- Assert.assertEquals( |
+ assertEquals( |
Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIntent.getAction()); |
Intent contentIntent = |
(Intent) mActivityWindowAndroidForTest.lastIntent.getParcelableExtra( |
Intent.EXTRA_INTENT); |
- Assert.assertNotNull(contentIntent); |
- Assert.assertFalse(contentIntent.hasCategory(Intent.CATEGORY_OPENABLE)); |
+ assertNotNull(contentIntent); |
+ assertFalse(contentIntent.hasCategory(Intent.CATEGORY_OPENABLE)); |
resetActivityWindowAndroidForTest(); |
} |
{ |
DOMUtils.clickNode(mContentViewCore, "input_text"); |
CriteriaHelper.pollInstrumentationThread(new IntentSentCriteria()); |
- Assert.assertEquals( |
+ assertEquals( |
Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIntent.getAction()); |
Intent contentIntent = |
(Intent) mActivityWindowAndroidForTest.lastIntent.getParcelableExtra( |
Intent.EXTRA_INTENT); |
- Assert.assertNotNull(contentIntent); |
- Assert.assertTrue(contentIntent.hasCategory(Intent.CATEGORY_OPENABLE)); |
+ assertNotNull(contentIntent); |
+ assertTrue(contentIntent.hasCategory(Intent.CATEGORY_OPENABLE)); |
resetActivityWindowAndroidForTest(); |
} |
{ |
DOMUtils.clickNode(mContentViewCore, "input_any"); |
CriteriaHelper.pollInstrumentationThread(new IntentSentCriteria()); |
- Assert.assertEquals( |
+ assertEquals( |
Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIntent.getAction()); |
Intent contentIntent = |
(Intent) mActivityWindowAndroidForTest.lastIntent.getParcelableExtra( |
Intent.EXTRA_INTENT); |
- Assert.assertNotNull(contentIntent); |
- Assert.assertFalse(contentIntent.hasCategory(Intent.CATEGORY_OPENABLE)); |
+ assertNotNull(contentIntent); |
+ assertFalse(contentIntent.hasCategory(Intent.CATEGORY_OPENABLE)); |
resetActivityWindowAndroidForTest(); |
} |
{ |
DOMUtils.clickNode(mContentViewCore, "input_file_multiple"); |
CriteriaHelper.pollInstrumentationThread(new IntentSentCriteria()); |
- Assert.assertEquals( |
+ assertEquals( |
Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIntent.getAction()); |
Intent contentIntent = |
(Intent) mActivityWindowAndroidForTest.lastIntent.getParcelableExtra( |
Intent.EXTRA_INTENT); |
- Assert.assertNotNull(contentIntent); |
- Assert.assertFalse(contentIntent.hasCategory(Intent.CATEGORY_OPENABLE)); |
+ assertNotNull(contentIntent); |
+ assertFalse(contentIntent.hasCategory(Intent.CATEGORY_OPENABLE)); |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { |
- Assert.assertTrue(contentIntent.hasExtra(Intent.EXTRA_ALLOW_MULTIPLE)); |
+ assertTrue(contentIntent.hasExtra(Intent.EXTRA_ALLOW_MULTIPLE)); |
} |
resetActivityWindowAndroidForTest(); |
} |
DOMUtils.clickNode(mContentViewCore, "input_image"); |
CriteriaHelper.pollInstrumentationThread(new IntentSentCriteria()); |
- Assert.assertEquals(MediaStore.ACTION_IMAGE_CAPTURE, |
+ assertEquals(MediaStore.ACTION_IMAGE_CAPTURE, |
mActivityWindowAndroidForTest.lastIntent.getAction()); |
resetActivityWindowAndroidForTest(); |
DOMUtils.clickNode(mContentViewCore, "input_audio"); |
CriteriaHelper.pollInstrumentationThread(new IntentSentCriteria()); |
- Assert.assertEquals(MediaStore.Audio.Media.RECORD_SOUND_ACTION, |
+ assertEquals(MediaStore.Audio.Media.RECORD_SOUND_ACTION, |
mActivityWindowAndroidForTest.lastIntent.getAction()); |
resetActivityWindowAndroidForTest(); |
} |