Chromium Code Reviews| Index: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeActivityTestRule.java |
| diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeActivityTestRule.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeActivityTestRule.java |
| index ba3d5cfa664603720c3ce49d691b71863f9e5157..6c9dd0bb6d3aa5ec7fcd7a8044df36417e534858 100644 |
| --- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeActivityTestRule.java |
| +++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeActivityTestRule.java |
| @@ -7,6 +7,7 @@ package org.chromium.content.browser; |
| import org.junit.runner.Description; |
| import org.junit.runners.model.Statement; |
| +import org.chromium.base.test.SetUpTestRule; |
| import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
| import org.chromium.content_shell_apk.ContentShellActivity; |
| import org.chromium.content_shell_apk.ContentShellActivityTestRule; |
| @@ -18,13 +19,10 @@ import java.lang.annotation.Annotation; |
| * ActivityTestRule with common functionality for testing the Java Bridge. |
| */ |
| public class JavaBridgeActivityTestRule |
| - extends ContentShellActivityTestRule implements TestCommonCallback<ContentShellActivity> { |
| - private JavaBridgeTestCommon mTestCommon; |
| - |
| - public JavaBridgeActivityTestRule() { |
| - super(); |
| - mTestCommon = new JavaBridgeTestCommon(this); |
| - } |
| + extends ContentShellActivityTestRule implements TestCommonCallback<ContentShellActivity>, |
| + SetUpTestRule<JavaBridgeActivityTestRule> { |
| + private JavaBridgeTestCommon mTestCommon = new JavaBridgeTestCommon(this); |
| + private boolean mRunSetUp = false; |
| /** |
| * Sets up the ContentView. Intended to be called from setUp(). |
| @@ -62,12 +60,17 @@ public class JavaBridgeActivityTestRule |
| @Override |
| public Statement apply(final Statement base, Description desc) { |
| - return super.apply(new Statement() { |
| - @Override |
| - public void evaluate() throws Throwable { |
| - setUpContentView(); |
| - base.evaluate(); |
| - } |
| - }, desc); |
| + return super.apply(new SetUpTestRule.SetUpStatement(base, this, mRunSetUp), desc); |
| + } |
| + |
| + @Override |
| + public JavaBridgeActivityTestRule shouldSetUp(boolean shouldSetUp) { |
|
jbudorick
2017/03/28 01:13:28
So every rule supporting this behavior would need
the real yoland
2017/03/28 01:32:50
ya, one way to decrease the boilerplate code is to
jbudorick
2017/03/28 01:36:59
Let's talk about this offline.
|
| + mRunSetUp = shouldSetUp; |
| + return this; |
| + } |
| + |
| + @Override |
| + public void setUp() { |
| + setUpContentView(); |
| } |
| } |