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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageSavePageLaterEvaluationTest.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/offlinepages/OfflinePageSavePageLaterEvaluationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageSavePageLaterEvaluationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageSavePageLaterEvaluationTest.java
index 80d445034d13ab082904f2f09b91ca3881c1af05..0a9240f53024700f882453e9e680854a3d2d604c 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageSavePageLaterEvaluationTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageSavePageLaterEvaluationTest.java
@@ -9,13 +9,6 @@
import android.os.Environment;
import android.text.TextUtils;
import android.util.LongSparseArray;
-
-import org.junit.After;
-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.Callback;
import org.chromium.base.ContextUtils;
@@ -25,12 +18,10 @@
import org.chromium.base.test.util.Manual;
import org.chromium.base.test.util.TimeoutScale;
import org.chromium.chrome.browser.ChromeActivity;
-import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.offlinepages.evaluation.OfflinePageEvaluationBridge;
import org.chromium.chrome.browser.offlinepages.evaluation.OfflinePageEvaluationBridge.OfflinePageEvaluationObserver;
import org.chromium.chrome.browser.profiles.Profile;
-import org.chromium.chrome.test.ChromeActivityTestRule;
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
import org.chromium.components.offlinepages.BackgroundSavePageResult;
import java.io.BufferedReader;
@@ -42,6 +33,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -55,19 +47,12 @@
* record metrics (failure rate, time elapsed etc.) by writing metrics to a file on external
* storage. This will always use prerenderer.
*/
-@RunWith(ChromeJUnit4ClassRunner.class)
-@CommandLineFlags.Add({"disable-features=BackgroundLoader",
- ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
-public class OfflinePageSavePageLaterEvaluationTest {
+@CommandLineFlags.Add({"disable-features=BackgroundLoader"})
+public class OfflinePageSavePageLaterEvaluationTest
+ extends ChromeActivityTestCaseBase<ChromeActivity> {
/**
* Class which is used to calculate time difference.
*/
-
- @Rule
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
- new ChromeActivityTestRule<>(ChromeActivity.class);
-
static class TimeDelta {
public void setStartTime(Long startTime) {
mStartTime = startTime;
@@ -118,15 +103,19 @@
private LongSparseArray<RequestMetadata> mRequestMetadata;
- @Before
- public void setUp() throws Exception {
- mActivityTestRule.startMainActivityOnBlankPage();
+ public OfflinePageSavePageLaterEvaluationTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
mRequestMetadata = new LongSparseArray<RequestMetadata>();
mCount = 0;
}
- @After
- public void tearDown() throws Exception {
+ @Override
+ protected void tearDown() throws Exception {
NotificationManager notificationManager =
(NotificationManager) ContextUtils.getApplicationContext().getSystemService(
Context.NOTIFICATION_SERVICE);
@@ -157,6 +146,12 @@
"Timed out when clearing remaining requests!");
mBridge.closeLog();
mBridge.destroy();
+ super.tearDown();
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
}
/**
@@ -217,7 +212,7 @@
private void checkTrue(boolean condition, String message) {
if (!condition) {
log(TAG, message);
- Assert.fail();
+ fail();
}
}
@@ -237,7 +232,7 @@
mBridge = new OfflinePageEvaluationBridge(
profile, useTestingScheduler, useBackgroundLoader);
if (mBridge == null) {
- Assert.fail("OfflinePageEvaluationBridge initialization failed!");
+ fail("OfflinePageEvaluationBridge initialization failed!");
return;
}
if (mBridge.isOfflinePageModelLoaded()) {
@@ -337,7 +332,7 @@
private void processUrls(List<String> urls) throws InterruptedException, IOException {
if (mBridge == null) {
- Assert.fail("Test initialization error, aborting. No results would be written.");
+ fail("Test initialization error, aborting. No results would be written.");
return;
}
int count = 0;
@@ -374,7 +369,7 @@
}
} catch (FileNotFoundException e) {
Log.e(TAG, e.getMessage(), e);
- Assert.fail(String.format("URL file %s is not found.", inputFilePath));
+ fail(String.format("URL file %s is not found.", inputFilePath));
}
}
@@ -502,11 +497,11 @@
Boolean.parseBoolean(properties.getProperty("UseBackgroundLoader"));
} catch (FileNotFoundException e) {
Log.e(TAG, e.getMessage(), e);
- Assert.fail(String.format(
+ fail(String.format(
"Config file %s is not found, aborting the test.", CONFIG_FILE_PATH));
} catch (NumberFormatException e) {
Log.e(TAG, e.getMessage(), e);
- Assert.fail("Error parsing config file, aborting test.");
+ fail("Error parsing config file, aborting test.");
} finally {
if (inputStream != null) {
inputStream.close();
@@ -523,10 +518,10 @@
* immediate processing also works on svelte devices. This flag will *not* affect normal
* devices.
*/
- @Test
@Manual
@TimeoutScale(4)
- @CommandLineFlags.Add({"enable-features=OfflinePagesSvelteConcurrentLoading"})
+ @CommandLineFlags
+ .Add({"enable-features=OfflinePagesSvelteConcurrentLoading"})
@CommandLineFlags.Remove({"disable-features=OfflinePagesSvelteConcurrentLoading"})
public void testFailureRate() throws IOException, InterruptedException {
parseConfigFile();
@@ -540,12 +535,12 @@
* immediate processing also works on svelte devices. This flag will *not* affect normal
* devices.
*/
- @Test
@Manual
@TimeoutScale(4)
- @CommandLineFlags.Add({"enable-features=BackgroundLoaderOfflinePagesSvelteConcurrentLoading"})
- @CommandLineFlags.Remove({
- "disable-features=BackgroundLoaderOfflinePagesSvelteConcurrentLoading"})
+ @CommandLineFlags
+ .Add({"enable-features=BackgroundLoader,OfflinePagesSvelteConcurrentLoading"})
+ @CommandLineFlags
+ .Remove({"disable-features=BackgroundLoader,OfflinePagesSvelteConcurrentLoading"})
public void testBackgroundLoaderFailureRate() throws IOException, InterruptedException {
testFailureRate();
}

Powered by Google App Engine
This is Rietveld 408576698