OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.test; |
| 6 |
| 7 import android.content.Context; |
| 8 |
| 9 import org.junit.rules.TestRule; |
| 10 import org.junit.runner.Description; |
| 11 import org.junit.runners.model.Statement; |
| 12 |
| 13 import org.chromium.chrome.test.util.ApplicationData; |
| 14 |
| 15 /** |
| 16 * JUnit test rule that just clears app data before each test. Having this as a
rule allows us |
| 17 * to ensure the order it's executed in with something like RuleChain, allowing
us to execute it |
| 18 * prior to launching the browser process. |
| 19 */ |
| 20 public class ClearAppDataTestRule implements TestRule { |
| 21 Context mContext; |
| 22 |
| 23 public ClearAppDataTestRule(Context context) { |
| 24 mContext = context; |
| 25 } |
| 26 |
| 27 @Override |
| 28 public Statement apply(final Statement base, Description description) { |
| 29 return new Statement() { |
| 30 @Override |
| 31 public void evaluate() throws Throwable { |
| 32 ApplicationData.clearAppData(mContext); |
| 33 } |
| 34 }; |
| 35 } |
| 36 } |
OLD | NEW |