| 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);
|
| + }
|
| + };
|
| + }
|
| +}
|
|
|