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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/document/LauncherActivityTest.java

Issue 2831823003: Convert ChromeActivityTestCaseBase direct children to JUnit4 (Closed)
Patch Set: rebase and convert newly added test 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/document/LauncherActivityTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/document/LauncherActivityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/document/LauncherActivityTest.java
index 20d9998438e2f7811b1beb9ee6a70096deb9c59a..b9f1d2267eb41b5ca7e5b9eea00ca2c4eacd65ee 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/document/LauncherActivityTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/document/LauncherActivityTest.java
@@ -13,13 +13,22 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
+import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import org.chromium.base.ApplicationState;
import org.chromium.base.ApplicationStatus;
+import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.chrome.browser.ChromeActivity;
-import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+import org.chromium.chrome.browser.ChromeSwitches;
+import org.chromium.chrome.test.ChromeActivityTestRule;
+import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
@@ -32,22 +41,20 @@ import java.util.concurrent.atomic.AtomicReference;
/**
* Tests for launching Chrome.
*/
+@RunWith(ChromeJUnit4ClassRunner.class)
@RetryOnFailure
-public class LauncherActivityTest extends ChromeActivityTestCaseBase<ChromeActivity> {
-
+@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
+ ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
+public class LauncherActivityTest {
private Context mContext;
private static final long DEVICE_STARTUP_TIMEOUT_MS = scaleTimeout(15000);
- public LauncherActivityTest() {
- super(ChromeActivity.class);
- }
-
- @Override
+ @Before
public void setUp() throws Exception {
- super.setUp();
- mContext = getInstrumentation().getTargetContext();
+ mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
}
+ @Test
@SmallTest
public void testLaunchWithUrlNoScheme() {
// Prepare intent
@@ -58,9 +65,10 @@ public class LauncherActivityTest extends ChromeActivityTestCaseBase<ChromeActiv
final Activity startedActivity = tryLaunchingChrome(intent);
final Intent activityIntent = startedActivity.getIntent();
- assertEquals(intentUrl, activityIntent.getDataString());
+ Assert.assertEquals(intentUrl, activityIntent.getDataString());
}
+ @Test
@SmallTest
public void testDoesNotCrashWithBadParcel() {
// Prepare bad intent
@@ -77,8 +85,9 @@ public class LauncherActivityTest extends ChromeActivityTestCaseBase<ChromeActiv
final Activity startedActivity = tryLaunchingChrome(intent);
final Intent activityIntent = startedActivity.getIntent();
- assertEquals("Data was not preserved", intent.getData(), activityIntent.getData());
- assertEquals("Action was not preserved", intent.getAction(), activityIntent.getAction());
+ Assert.assertEquals("Data was not preserved", intent.getData(), activityIntent.getData());
+ Assert.assertEquals(
+ "Action was not preserved", intent.getAction(), activityIntent.getAction());
}
private Activity tryLaunchingChrome(final Intent intent) {
@@ -109,10 +118,6 @@ public class LauncherActivityTest extends ChromeActivityTestCaseBase<ChromeActiv
return launchedActivity.get();
}
- @Override
- public void startMainActivity() throws InterruptedException {
- }
-
/**
* This Parcelable does not adhere to the form standards of a well formed Parcelable and will
* thus cause a BadParcelableException. The lint suppression is needed since it detects that

Powered by Google App Engine
This is Rietveld 408576698