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

Unified Diff: base/test/android/javatests/src/org/chromium/base/test/SetUpStatement.java

Issue 2770393002: Add setup action interface (Closed)
Patch Set: Add tests Created 3 years, 8 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
« no previous file with comments | « base/BUILD.gn ('k') | base/test/android/javatests/src/org/chromium/base/test/SetUpTestRule.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/android/javatests/src/org/chromium/base/test/SetUpStatement.java
diff --git a/base/test/android/javatests/src/org/chromium/base/test/SetUpStatement.java b/base/test/android/javatests/src/org/chromium/base/test/SetUpStatement.java
new file mode 100644
index 0000000000000000000000000000000000000000..30ac2b6c5cb666427cd17646919e73d2f08eddfb
--- /dev/null
+++ b/base/test/android/javatests/src/org/chromium/base/test/SetUpStatement.java
@@ -0,0 +1,35 @@
+// 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.base.test;
+
+import org.junit.rules.TestRule;
+import org.junit.runners.model.Statement;
+
+/**
+ * Custom Statement for SetUpTestRules.
+ *
+ * Calls {@link SetUpTestRule#setUp} before evaluating {@link SetUpTestRule#base} if
+ * {@link SetUpTestRule#shouldSetUp} is true
+ */
+public class SetUpStatement extends Statement {
+ private final Statement mBase;
+ private final SetUpTestRule<? extends TestRule> mSetUpTestRule;
+ private final boolean mShouldSetUp;
+
+ public SetUpStatement(
+ final Statement base, SetUpTestRule<? extends TestRule> callback, boolean shouldSetUp) {
+ mBase = base;
+ mSetUpTestRule = callback;
+ mShouldSetUp = shouldSetUp;
+ }
+
+ @Override
+ public void evaluate() throws Throwable {
+ if (mShouldSetUp) {
+ mSetUpTestRule.setUp();
+ }
+ mBase.evaluate();
+ }
+}
« no previous file with comments | « base/BUILD.gn ('k') | base/test/android/javatests/src/org/chromium/base/test/SetUpTestRule.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698