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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/TabTest.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/TabTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/TabTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/TabTest.java
index 1b430e0b3c36d4f223d6634fcd55e4549cd9b46f..802c3ea1a73cb84bed8a23b84650e9cac235a72b 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/TabTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/TabTest.java
@@ -5,26 +5,17 @@
package org.chromium.chrome.browser;
import android.app.Activity;
-import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
-
-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.CallbackHelper;
-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.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabObserver;
import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType;
-import org.chromium.chrome.test.ChromeActivityTestRule;
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
import org.chromium.chrome.test.util.ApplicationTestUtils;
import org.chromium.components.security_state.ConnectionSecurityLevel;
import org.chromium.content.browser.test.util.Criteria;
@@ -33,15 +24,8 @@
/**
* Tests for Tab class.
*/
-@RunWith(ChromeJUnit4ClassRunner.class)
@RetryOnFailure
-@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
-public class TabTest {
- @Rule
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
- new ChromeActivityTestRule<>(ChromeActivity.class);
-
+public class TabTest extends ChromeActivityTestCaseBase<ChromeActivity> {
private Tab mTab;
private CallbackHelper mOnTitleUpdatedHelper;
@@ -52,39 +36,46 @@
}
};
- @Before
- public void setUp() throws Exception {
- mActivityTestRule.startMainActivityOnBlankPage();
- mTab = mActivityTestRule.getActivity().getActivityTab();
+ public TabTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mTab = getActivity().getActivityTab();
mTab.addObserver(mTabObserver);
mOnTitleUpdatedHelper = new CallbackHelper();
}
- @Test
@SmallTest
@Feature({"Tab"})
public void testTabContext() throws Throwable {
- Assert.assertFalse("The tab context cannot be an activity",
+ assertFalse("The tab context cannot be an activity",
mTab.getContentViewCore().getContext() instanceof Activity);
- Assert.assertNotSame("The tab context's theme should have been updated",
+ assertNotSame("The tab context's theme should have been updated",
mTab.getContentViewCore().getContext().getTheme(),
- mActivityTestRule.getActivity().getApplication().getTheme());
+ getActivity().getApplication().getTheme());
}
- @Test
@SmallTest
@Feature({"Tab"})
public void testTitleDelayUpdate() throws Throwable {
final String oldTitle = "oldTitle";
final String newTitle = "newTitle";
- mActivityTestRule.loadUrl("data:text/html;charset=utf-8,<html><head><title>" + oldTitle
- + "</title></head><body/></html>");
- Assert.assertEquals("title does not match initial title", oldTitle, mTab.getTitle());
+ loadUrl("data:text/html;charset=utf-8,<html><head><title>"
+ + oldTitle + "</title></head><body/></html>");
+ assertEquals("title does not match initial title", oldTitle, mTab.getTitle());
int currentCallCount = mOnTitleUpdatedHelper.getCallCount();
- mActivityTestRule.runJavaScriptCodeInCurrentTab("document.title='" + newTitle + "';");
+ runJavaScriptCodeInCurrentTab("document.title='" + newTitle + "';");
mOnTitleUpdatedHelper.waitForCallback(currentCallCount);
- Assert.assertEquals("title does not update", newTitle, mTab.getTitle());
+ assertEquals("title does not update", newTitle, mTab.getTitle());
}
/**
@@ -93,7 +84,6 @@
* Note that document mode is explicitly disabled, as the document activity
* may be fully recreated if its contents is killed while in the background.
*/
- @Test
@SmallTest
@Feature({"Tab"})
public void testTabRestoredIfKilledWhileActivityStopped() throws Exception {
@@ -105,13 +95,12 @@
}
});
- Assert.assertFalse(mTab.needsReload());
- Assert.assertFalse(mTab.isHidden());
- Assert.assertFalse(mTab.isShowingSadTab());
+ assertFalse(mTab.needsReload());
+ assertFalse(mTab.isHidden());
+ assertFalse(mTab.isShowingSadTab());
// Stop the activity and simulate a killed renderer.
- ApplicationTestUtils.fireHomeScreenIntent(
- InstrumentationRegistry.getInstrumentation().getTargetContext());
+ ApplicationTestUtils.fireHomeScreenIntent(getInstrumentation().getTargetContext());
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
@@ -125,11 +114,10 @@
return mTab.isHidden();
}
});
- Assert.assertTrue(mTab.needsReload());
- Assert.assertFalse(mTab.isShowingSadTab());
+ assertTrue(mTab.needsReload());
+ assertFalse(mTab.isShowingSadTab());
- ApplicationTestUtils.launchChrome(
- InstrumentationRegistry.getInstrumentation().getTargetContext());
+ ApplicationTestUtils.launchChrome(getInstrumentation().getTargetContext());
// The tab should be restored and visible.
CriteriaHelper.pollUiThread(new Criteria() {
@@ -138,18 +126,17 @@
return !mTab.isHidden();
}
});
- Assert.assertFalse(mTab.needsReload());
- Assert.assertFalse(mTab.isShowingSadTab());
+ assertFalse(mTab.needsReload());
+ assertFalse(mTab.isShowingSadTab());
}
- @Test
@SmallTest
@Feature({"Tab"})
public void testTabSecurityLevel() {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- Assert.assertEquals(ConnectionSecurityLevel.NONE, mTab.getSecurityLevel());
+ assertEquals(ConnectionSecurityLevel.NONE, mTab.getSecurityLevel());
}
});
}

Powered by Google App Engine
This is Rietveld 408576698