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

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

Issue 2954393003: Fix test crashes related to AccountManagerHelper. (Closed)
Patch Set: . Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.test; 5 package org.chromium.chrome.browser.test;
6 6
7 import android.content.Context; 7 import android.support.test.InstrumentationRegistry;
8 8
9 import org.junit.rules.TestRule; 9 import org.junit.rules.TestRule;
10 import org.junit.runner.Description; 10 import org.junit.runner.Description;
11 import org.junit.runners.model.Statement; 11 import org.junit.runners.model.Statement;
12 12
13 import org.chromium.chrome.test.util.ApplicationData; 13 import org.chromium.chrome.test.util.ApplicationData;
14 14
15 /** 15 /**
16 * JUnit test rule that just clears app data before each test. Having this as a rule allows us 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 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. 18 * prior to launching the browser process.
19 */ 19 */
20 public class ClearAppDataTestRule implements TestRule { 20 public class ClearAppDataTestRule implements TestRule {
21 Context mContext;
22
23 public ClearAppDataTestRule(Context context) {
24 mContext = context;
25 }
26
27 @Override 21 @Override
28 public Statement apply(final Statement base, Description description) { 22 public Statement apply(final Statement base, Description description) {
29 return new Statement() { 23 return new Statement() {
30 @Override 24 @Override
31 public void evaluate() throws Throwable { 25 public void evaluate() throws Throwable {
32 ApplicationData.clearAppData(mContext); 26 ApplicationData.clearAppData(InstrumentationRegistry.getContext( ));
33 } 27 }
34 }; 28 };
35 } 29 }
36 } 30 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698