OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.base.test; |
| 6 |
| 7 import org.junit.rules.TestRule; |
| 8 import org.junit.runners.model.Statement; |
| 9 |
| 10 /** |
| 11 * Custom Statement for SetUpTestRules. |
| 12 * |
| 13 * Calls {@link SetUpTestRule#setUp} before evaluating {@link SetUpTestRule#base
} if |
| 14 * {@link SetUpTestRule#shouldSetUp} is true |
| 15 */ |
| 16 public class SetUpStatement extends Statement { |
| 17 private final Statement mBase; |
| 18 private final SetUpTestRule<? extends TestRule> mSetUpTestRule; |
| 19 private final boolean mShouldSetUp; |
| 20 |
| 21 public SetUpStatement( |
| 22 final Statement base, SetUpTestRule<? extends TestRule> callback, bo
olean shouldSetUp) { |
| 23 mBase = base; |
| 24 mSetUpTestRule = callback; |
| 25 mShouldSetUp = shouldSetUp; |
| 26 } |
| 27 |
| 28 @Override |
| 29 public void evaluate() throws Throwable { |
| 30 if (mShouldSetUp) { |
| 31 mSetUpTestRule.setUp(); |
| 32 } |
| 33 mBase.evaluate(); |
| 34 } |
| 35 } |
OLD | NEW |