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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeActivityTestRule.java

Issue 2770393002: Add setup action interface (Closed)
Patch Set: address comments Created 3 years, 9 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
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();
}
}

Powered by Google App Engine
This is Rietveld 408576698