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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/test/ClearAppDataTestRule.java

Issue 2962893002: Add a JUnit test rule for clearing app data prior to testing. (Closed)
Patch Set: . Created 3 years, 6 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
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/test/ClearAppDataTestRule.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/test/ClearAppDataTestRule.java b/chrome/android/javatests/src/org/chromium/chrome/browser/test/ClearAppDataTestRule.java
new file mode 100644
index 0000000000000000000000000000000000000000..2a3009a90cbfbdb0c1ca3ebff2d0a84be5858fbb
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/test/ClearAppDataTestRule.java
@@ -0,0 +1,36 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.test;
+
+import android.content.Context;
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import org.chromium.chrome.test.util.ApplicationData;
+
+/**
+ * JUnit test rule that just clears app data before each test. Having this as a rule allows us
+ * to ensure the order it's executed in with something like RuleChain, allowing us to execute it
+ * prior to launching the browser process.
+ */
+public class ClearAppDataTestRule implements TestRule {
+ Context mContext;
+
+ public ClearAppDataTestRule(Context context) {
+ mContext = context;
+ }
+
+ @Override
+ public Statement apply(final Statement base, Description description) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ ApplicationData.clearAppData(mContext);
+ }
+ };
+ }
+}
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698