Chromium Code Reviews| 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..2c672ef2890b80477a97357ef8a0ce4fe7380624 |
| --- /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. |
| + * |
| + * The statment calls {@link SetUpTestRule#setUp} before test run based on |
|
jbudorick
2017/04/10 19:08:45
rephrase: Calls {@link SetUpTestRule.setUp()} befo
the real yoland
2017/04/12 00:52:34
Done
|
| + * {@link SetUpTestRule#shouldSetUp} argument |
| + */ |
| +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(); |
| + } |
| +} |