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

Side by Side Diff: base/test/android/junit/src/org/chromium/base/test/SetUpStatementTest.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 unified diff | Download patch
« no previous file with comments | « base/test/android/javatests/src/org/chromium/base/test/SetUpTestRule.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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.Assert;
8 import org.junit.Before;
9 import org.junit.Test;
10 import org.junit.rules.TestRule;
11 import org.junit.runner.RunWith;
12 import org.junit.runners.BlockJUnit4ClassRunner;
13 import org.junit.runners.model.Statement;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 /**
19 * Test SetUpStatement is working as intended with SetUpTestRule.
20 */
21 @RunWith(BlockJUnit4ClassRunner.class)
22 public class SetUpStatementTest {
23 private Statement mBase;
24 private SetUpTestRule<TestRule> mRule;
25 private List<Integer> mList;
26
27 @Before
28 public void setUp() {
29 mBase = new Statement() {
30 @Override
31 public void evaluate() {
32 mList.add(1);
33 }
34 };
35 mList = new ArrayList<>();
36 mRule = new SetUpTestRule<TestRule>() {
37 @Override
38 public void setUp() {
39 mList.add(0);
40 }
41
42 @Override
43 public TestRule shouldSetUp(boolean toSetUp) {
44 return null;
45 }
46 };
47 }
48
49 @Test
50 public void testSetUpStatementShouldSetUp() throws Throwable {
51 SetUpStatement statement = new SetUpStatement(mBase, mRule, true);
52 statement.evaluate();
53 Integer[] expected = {0, 1};
54 Assert.assertArrayEquals(expected, mList.toArray());
55 }
56
57 @Test
58 public void testSetUpStatementShouldNotSetUp() throws Throwable {
59 SetUpStatement statement = new SetUpStatement(mBase, mRule, false);
60 statement.evaluate();
61 Integer[] expected = {1};
62 Assert.assertArrayEquals(expected, mList.toArray());
63 }
64 }
OLDNEW
« no previous file with comments | « base/test/android/javatests/src/org/chromium/base/test/SetUpTestRule.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698