Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / android_webview / javatests / src / org / chromium / android_webview / test / CommandLineTest.java
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.
4
5 package org.chromium.android_webview.test;
6
7 import android.test.suitebuilder.annotation.SmallTest;
8
9 import org.chromium.android_webview.AwBrowserProcess;
10 import org.chromium.base.CommandLine;
11 import org.chromium.base.test.util.Feature;
12
13 /**
14  * Test suite for setting by the command line.
15  */
16 public class CommandLineTest extends AwTestBase {
17     @Override
18     protected boolean needsBrowserProcessStarted() {
19         return false;
20     }
21
22     @SmallTest
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());
28
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"));
34
35         // Setup Chrome.
36         AwBrowserProcess.loadLibrary();
37
38         // Now we should have switched to a native backed command line:
39         cl = CommandLine.getInstance();
40         assertTrue(cl.isNativeImplementation());
41
42         // Our first switch is still there.
43         assertTrue(cl.hasSwitch("magic-switch"));
44         assertEquals("magic", cl.getSwitchValue("magic-switch"));
45
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"));
51     }
52 }