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

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

Issue 2726003002: Auto convert base javatests in content shell apk to JUnit4 (Closed)
Patch Set: Rebase Created 3 years, 9 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
Index: base/android/javatests/src/org/chromium/base/CommandLineTest.java
diff --git a/base/android/javatests/src/org/chromium/base/CommandLineTest.java b/base/android/javatests/src/org/chromium/base/CommandLineTest.java
index 3c079357e1acc18b96e6e827840b158c8395474a..47749fb351333b31f5902044173674414b6c3be7 100644
--- a/base/android/javatests/src/org/chromium/base/CommandLineTest.java
+++ b/base/android/javatests/src/org/chromium/base/CommandLineTest.java
@@ -1,15 +1,21 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// 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;
import android.support.test.filters.SmallTest;
-import android.test.InstrumentationTestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
-public class CommandLineTest extends InstrumentationTestCase {
+@RunWith(BaseJUnit4ClassRunner.class)
+public class CommandLineTest {
// A reference command line. Note that switch2 is [brea\d], switch3 is [and "butter"],
// and switch4 is [a "quoted" 'food'!]
static final String INIT_SWITCHES[] = { "init_command", "--SWITCH", "Arg",
@@ -27,60 +33,61 @@ public class CommandLineTest extends InstrumentationTestCase {
static final String CL_ADDED_SWITCH_2 = "username";
static final String CL_ADDED_VALUE_2 = "bozo";
- @Override
+ @Before
public void setUp() throws Exception {
CommandLine.reset();
}
void checkInitSwitches() {
CommandLine cl = CommandLine.getInstance();
- assertFalse(cl.hasSwitch("init_command"));
- assertFalse(cl.hasSwitch("switch"));
- assertTrue(cl.hasSwitch("SWITCH"));
- assertFalse(cl.hasSwitch("--SWITCH"));
- assertFalse(cl.hasSwitch("Arg"));
- assertFalse(cl.hasSwitch("actually_an_arg"));
- assertEquals("brea\\d", cl.getSwitchValue("switch2"));
- assertEquals("and \"butter\"", cl.getSwitchValue("switch3"));
- assertEquals("a \"quoted\" 'food'!", cl.getSwitchValue("switch4"));
- assertNull(cl.getSwitchValue("SWITCH"));
- assertNull(cl.getSwitchValue("non-existant"));
+ Assert.assertFalse(cl.hasSwitch("init_command"));
+ Assert.assertFalse(cl.hasSwitch("switch"));
+ Assert.assertTrue(cl.hasSwitch("SWITCH"));
+ Assert.assertFalse(cl.hasSwitch("--SWITCH"));
+ Assert.assertFalse(cl.hasSwitch("Arg"));
+ Assert.assertFalse(cl.hasSwitch("actually_an_arg"));
+ Assert.assertEquals("brea\\d", cl.getSwitchValue("switch2"));
+ Assert.assertEquals("and \"butter\"", cl.getSwitchValue("switch3"));
+ Assert.assertEquals("a \"quoted\" 'food'!", cl.getSwitchValue("switch4"));
+ Assert.assertNull(cl.getSwitchValue("SWITCH"));
+ Assert.assertNull(cl.getSwitchValue("non-existant"));
}
void checkSettingThenGetting() {
CommandLine cl = CommandLine.getInstance();
// Add a plain switch.
- assertFalse(cl.hasSwitch(CL_ADDED_SWITCH));
+ Assert.assertFalse(cl.hasSwitch(CL_ADDED_SWITCH));
cl.appendSwitch(CL_ADDED_SWITCH);
- assertTrue(cl.hasSwitch(CL_ADDED_SWITCH));
+ Assert.assertTrue(cl.hasSwitch(CL_ADDED_SWITCH));
// Add a switch paired with a value.
- assertFalse(cl.hasSwitch(CL_ADDED_SWITCH_2));
- assertNull(cl.getSwitchValue(CL_ADDED_SWITCH_2));
+ Assert.assertFalse(cl.hasSwitch(CL_ADDED_SWITCH_2));
+ Assert.assertNull(cl.getSwitchValue(CL_ADDED_SWITCH_2));
cl.appendSwitchWithValue(CL_ADDED_SWITCH_2, CL_ADDED_VALUE_2);
- assertTrue(CL_ADDED_VALUE_2.equals(cl.getSwitchValue(CL_ADDED_SWITCH_2)));
+ Assert.assertTrue(CL_ADDED_VALUE_2.equals(cl.getSwitchValue(CL_ADDED_SWITCH_2)));
// Append a few new things.
final String switchesAndArgs[] = { "dummy", "--superfast", "--speed=turbo" };
- assertFalse(cl.hasSwitch("dummy"));
- assertFalse(cl.hasSwitch("superfast"));
- assertNull(cl.getSwitchValue("speed"));
+ Assert.assertFalse(cl.hasSwitch("dummy"));
+ Assert.assertFalse(cl.hasSwitch("superfast"));
+ Assert.assertNull(cl.getSwitchValue("speed"));
cl.appendSwitchesAndArguments(switchesAndArgs);
- assertFalse(cl.hasSwitch("dummy"));
- assertFalse(cl.hasSwitch("command"));
- assertTrue(cl.hasSwitch("superfast"));
- assertTrue("turbo".equals(cl.getSwitchValue("speed")));
+ Assert.assertFalse(cl.hasSwitch("dummy"));
+ Assert.assertFalse(cl.hasSwitch("command"));
+ Assert.assertTrue(cl.hasSwitch("superfast"));
+ Assert.assertTrue("turbo".equals(cl.getSwitchValue("speed")));
}
void checkTokenizer(String[] expected, String toParse) {
String[] actual = CommandLine.tokenizeQuotedAruments(toParse.toCharArray());
- assertEquals(expected.length, actual.length);
+ Assert.assertEquals(expected.length, actual.length);
for (int i = 0; i < expected.length; ++i) {
- assertEquals("comparing element " + i, expected[i], actual[i]);
+ Assert.assertEquals("comparing element " + i, expected[i], actual[i]);
}
}
+ @Test
@SmallTest
@Feature({"Android-AppBase"})
public void testJavaInitialization() {
@@ -89,6 +96,7 @@ public class CommandLineTest extends InstrumentationTestCase {
checkSettingThenGetting();
}
+ @Test
@SmallTest
@Feature({"Android-AppBase"})
public void testBufferInitialization() {
@@ -97,6 +105,7 @@ public class CommandLineTest extends InstrumentationTestCase {
checkSettingThenGetting();
}
+ @Test
@SmallTest
@Feature({"Android-AppBase"})
public void testArgumentTokenizer() {

Powered by Google App Engine
This is Rietveld 408576698