1 // Copyright 2014 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.
5 package org.chromium.android_webview.test;
7 import android.test.suitebuilder.annotation.SmallTest;
9 import org.chromium.android_webview.AwBrowserProcess;
10 import org.chromium.base.CommandLine;
11 import org.chromium.base.test.util.Feature;
14 * Test suite for setting by the command line.
16 public class CommandLineTest extends AwTestBase {
18 protected boolean needsBrowserProcessStarted() {
23 @Feature({"AndroidWebView"})
24 public void testSetupCommandLine() throws Exception {
25 // The commandline starts off in Java:
26 CommandLine cl = CommandLine.getInstance();
27 assertFalse(cl.isNativeImplementation());
29 // We can add a switch.
30 assertFalse(cl.hasSwitch("magic-switch"));
31 cl.appendSwitchWithValue("magic-switch", "magic");
32 assertTrue(cl.hasSwitch("magic-switch"));
33 assertEquals("magic", cl.getSwitchValue("magic-switch"));
36 AwBrowserProcess.loadLibrary();
38 // Now we should have switched to a native backed command line:
39 cl = CommandLine.getInstance();
40 assertTrue(cl.isNativeImplementation());
42 // Our first switch is still there.
43 assertTrue(cl.hasSwitch("magic-switch"));
44 assertEquals("magic", cl.getSwitchValue("magic-switch"));
46 // And we can add another one.
47 assertFalse(cl.hasSwitch("more-magic-switch"));
48 cl.appendSwitchWithValue("more-magic-switch", "more-magic");
49 assertTrue(cl.hasSwitch("more-magic-switch"));
50 assertEquals("more-magic", cl.getSwitchValue("more-magic-switch"));