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.library_loader.LibraryLoader;
12 import org.chromium.base.test.util.Feature;
15 * Test suite for setting by the command line.
17 public class CommandLineTest extends AwTestBase {
19 protected boolean needsBrowserProcessStarted() {
24 @Feature({"AndroidWebView"})
25 public void testSetupCommandLine() throws Exception {
26 // The commandline starts off in Java:
27 CommandLine cl = CommandLine.getInstance();
28 assertFalse(cl.isNativeImplementation());
30 // We can add a switch.
31 assertFalse(cl.hasSwitch("magic-switch"));
32 cl.appendSwitchWithValue("magic-switch", "magic");
33 assertTrue(cl.hasSwitch("magic-switch"));
34 assertEquals("magic", cl.getSwitchValue("magic-switch"));
37 AwBrowserProcess.loadLibrary();
38 LibraryLoader.switchCommandLineForWebView();
40 // Now we should have switched to a native backed command line:
41 cl = CommandLine.getInstance();
42 assertTrue(cl.isNativeImplementation());
44 // Our first switch is still there.
45 assertTrue(cl.hasSwitch("magic-switch"));
46 assertEquals("magic", cl.getSwitchValue("magic-switch"));
48 // And we can add another one.
49 assertFalse(cl.hasSwitch("more-magic-switch"));
50 cl.appendSwitchWithValue("more-magic-switch", "more-magic");
51 assertTrue(cl.hasSwitch("more-magic-switch"));
52 assertEquals("more-magic", cl.getSwitchValue("more-magic-switch"));