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 5package org.chromium.android_webview.test; 6 7import android.test.suitebuilder.annotation.SmallTest; 8 9import org.chromium.android_webview.AwBrowserProcess; 10import org.chromium.base.CommandLine; 11import org.chromium.base.library_loader.LibraryLoader; 12import org.chromium.base.test.util.Feature; 13 14/** 15 * Test suite for setting by the command line. 16 */ 17public class CommandLineTest extends AwTestBase { 18 @Override 19 protected boolean needsBrowserProcessStarted() { 20 return false; 21 } 22 23 @SmallTest 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()); 29 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")); 35 36 // Setup Chrome. 37 AwBrowserProcess.loadLibrary(); 38 LibraryLoader.switchCommandLineForWebView(); 39 40 // Now we should have switched to a native backed command line: 41 cl = CommandLine.getInstance(); 42 assertTrue(cl.isNativeImplementation()); 43 44 // Our first switch is still there. 45 assertTrue(cl.hasSwitch("magic-switch")); 46 assertEquals("magic", cl.getSwitchValue("magic-switch")); 47 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")); 53 } 54} 55