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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/android/junit/src/org/chromium/base/test/SetUpStatementTest.java
diff --git a/base/test/android/junit/src/org/chromium/base/test/SetUpStatementTest.java b/base/test/android/junit/src/org/chromium/base/test/SetUpStatementTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..722bd1acfe5160c1db4af67445e245856222b4c6
--- /dev/null
+++ b/base/test/android/junit/src/org/chromium/base/test/SetUpStatementTest.java
@@ -0,0 +1,64 @@
+// 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.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.Statement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Test SetUpStatement is working as intended with SetUpTestRule.
+ */
+@RunWith(BlockJUnit4ClassRunner.class)
+public class SetUpStatementTest {
+ private Statement mBase;
+ private SetUpTestRule<TestRule> mRule;
+ private List<Integer> mList;
+
+ @Before
+ public void setUp() {
+ mBase = new Statement() {
+ @Override
+ public void evaluate() {
+ mList.add(1);
+ }
+ };
+ mList = new ArrayList<>();
+ mRule = new SetUpTestRule<TestRule>() {
+ @Override
+ public void setUp() {
+ mList.add(0);
+ }
+
+ @Override
+ public TestRule shouldSetUp(boolean toSetUp) {
+ return null;
+ }
+ };
+ }
+
+ @Test
+ public void testSetUpStatementShouldSetUp() throws Throwable {
+ SetUpStatement statement = new SetUpStatement(mBase, mRule, true);
+ statement.evaluate();
+ Integer[] expected = {0, 1};
+ Assert.assertArrayEquals(expected, mList.toArray());
+ }
+
+ @Test
+ public void testSetUpStatementShouldNotSetUp() throws Throwable {
+ SetUpStatement statement = new SetUpStatement(mBase, mRule, false);
+ statement.evaluate();
+ Integer[] expected = {1};
+ Assert.assertArrayEquals(expected, mList.toArray());
+ }
+}
« 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