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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.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/tab/SadTabTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java
index 23ca61c4264e28a4433f1e4a16a2535dcc939d99..c0857975e15a6125b7b9d1f6bcbaedc1926be5b4 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/SadTabTest.java
@@ -7,53 +7,66 @@ package org.chromium.chrome.browser.tab;
import android.support.test.filters.SmallTest;
import android.widget.Button;
+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.chrome.R;
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;
/**
* Tests related to the sad tab logic.
*/
+@RunWith(ChromeJUnit4ClassRunner.class)
@RetryOnFailure
-public class SadTabTest extends ChromeActivityTestCaseBase<ChromeActivity> {
-
- public SadTabTest() {
- super(ChromeActivity.class);
- }
-
- @Override
- public void startMainActivity() throws InterruptedException {
- startMainActivityOnBlankPage();
+@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
+ ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
+public class SadTabTest {
+ @Rule
+ public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
+ new ChromeActivityTestRule<>(ChromeActivity.class);
+
+ @Before
+ public void setUp() throws InterruptedException {
+ mActivityTestRule.startMainActivityOnBlankPage();
}
/**
* Verify that the sad tab is shown when the renderer crashes.
*/
+ @Test
@SmallTest
@Feature({"SadTab"})
public void testSadTabShownWhenRendererProcessKilled() {
- final Tab tab = getActivity().getActivityTab();
+ final Tab tab = mActivityTestRule.getActivity().getActivityTab();
- assertFalse(tab.isShowingSadTab());
+ Assert.assertFalse(tab.isShowingSadTab());
simulateRendererKilled(tab, true);
- assertTrue(tab.isShowingSadTab());
+ Assert.assertTrue(tab.isShowingSadTab());
}
/**
* Verify that the sad tab is not shown when the renderer crashes in the background or the
* renderer was killed by the OS out-of-memory killer.
*/
+ @Test
@SmallTest
@Feature({"SadTab"})
public void testSadTabNotShownWhenRendererProcessKilledInBackround() {
- final Tab tab = getActivity().getActivityTab();
+ final Tab tab = mActivityTestRule.getActivity().getActivityTab();
- assertFalse(tab.isShowingSadTab());
+ Assert.assertFalse(tab.isShowingSadTab());
simulateRendererKilled(tab, false);
- assertFalse(tab.isShowingSadTab());
+ Assert.assertFalse(tab.isShowingSadTab());
}
/**
@@ -63,32 +76,39 @@ public class SadTabTest extends ChromeActivityTestCaseBase<ChromeActivity> {
* @throws InterruptedException
* @throws IllegalArgumentException
*/
+ @Test
@SmallTest
@Feature({"SadTab"})
public void testSadTabPageButtonText() throws IllegalArgumentException, InterruptedException {
- final Tab tab = getActivity().getActivityTab();
+ final Tab tab = mActivityTestRule.getActivity().getActivityTab();
- assertFalse(tab.isShowingSadTab());
+ Assert.assertFalse(tab.isShowingSadTab());
simulateRendererKilled(tab, true);
- assertTrue(tab.isShowingSadTab());
+ Assert.assertTrue(tab.isShowingSadTab());
String actualText = getSadTabButton(tab).getText().toString();
- assertEquals("Expected the sad tab button to have the reload label",
- getActivity().getString(R.string.sad_tab_reload_label), actualText);
+ Assert.assertEquals("Expected the sad tab button to have the reload label",
+ mActivityTestRule.getActivity().getString(R.string.sad_tab_reload_label),
+ actualText);
reloadSadTab(tab);
- assertTrue(tab.isShowingSadTab());
+ Assert.assertTrue(tab.isShowingSadTab());
actualText = getSadTabButton(tab).getText().toString();
- assertEquals(
+ Assert.assertEquals(
"Expected the sad tab button to have the feedback label after the tab button "
- + "crashes twice in a row.",
- getActivity().getString(R.string.sad_tab_send_feedback_label), actualText);
- loadUrl("about:blank");
- assertFalse("Expected about:blank to destroy the sad tab however the sad tab is still in "
- + "view", tab.isShowingSadTab());
+ + "crashes twice in a row.",
+ mActivityTestRule.getActivity().getString(R.string.sad_tab_send_feedback_label),
+ actualText);
+ mActivityTestRule.loadUrl("about:blank");
+ Assert.assertFalse(
+ "Expected about:blank to destroy the sad tab however the sad tab is still in "
+ + "view",
+ tab.isShowingSadTab());
simulateRendererKilled(tab, true);
actualText = getSadTabButton(tab).getText().toString();
- assertEquals("Expected the sad tab button to have the reload label after a successful load",
- getActivity().getString(R.string.sad_tab_reload_label), actualText);
+ Assert.assertEquals(
+ "Expected the sad tab button to have the reload label after a successful load",
+ mActivityTestRule.getActivity().getString(R.string.sad_tab_reload_label),
+ actualText);
}
/**

Powered by Google App Engine
This is Rietveld 408576698