OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.test.InstrumentationTestCase; | 7 import android.test.InstrumentationTestCase; |
8 import android.test.suitebuilder.annotation.MediumTest; | 8 import android.test.suitebuilder.annotation.MediumTest; |
9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
10 | 10 |
11 import org.chromium.base.test.util.Feature; | 11 import org.chromium.base.test.util.Feature; |
12 import org.chromium.content.app.LibraryLoader; | 12 import org.chromium.content.app.LibraryLoader; |
13 import org.chromium.content.common.CommandLine; | 13 import org.chromium.content.common.CommandLine; |
| 14 import org.chromium.content.common.ProcessInitException; |
14 import org.chromium.content_shell.ContentShellActivity; | 15 import org.chromium.content_shell.ContentShellActivity; |
15 import org.chromium.content_shell.ContentShellApplication; | 16 import org.chromium.content_shell.ContentShellApplication; |
16 | 17 |
17 public class CommandLineTest extends InstrumentationTestCase { | 18 public class CommandLineTest extends InstrumentationTestCase { |
18 // A reference command line. Note that switch2 is [brea\d], switch3 is [and
"butter"] | 19 // A reference command line. Note that switch2 is [brea\d], switch3 is [and
"butter"] |
19 static final String INIT_SWITCHES[] = { "init_command", "--SWITCH", "Arg", | 20 static final String INIT_SWITCHES[] = { "init_command", "--SWITCH", "Arg", |
20 "--switch2=brea\\d", "--switch3=and \"butter\"", "--", "--actually_an_ar
g" }; | 21 "--switch2=brea\\d", "--switch3=and \"butter\"", "--", "--actually_an_ar
g" }; |
21 | 22 |
22 // The same command line, but in quoted string format. | 23 // The same command line, but in quoted string format. |
23 static final char INIT_SWITCHES_BUFFER[] = | 24 static final char INIT_SWITCHES_BUFFER[] = |
24 ("init_command --SWITCH Arg --switch2=brea\\d --switch3=\"and \\\"butt\"
er\\\" " | 25 ("init_command --SWITCH Arg --switch2=brea\\d --switch3=\"and \\\"butt\"
er\\\" " |
25 + "-- --actually_an_arg").toCharArray(); | 26 + "-- --actually_an_arg").toCharArray(); |
26 | 27 |
27 static final String CL_ADDED_SWITCH = "zappo-dappo-doggy-trainer"; | 28 static final String CL_ADDED_SWITCH = "zappo-dappo-doggy-trainer"; |
28 static final String CL_ADDED_SWITCH_2 = "username"; | 29 static final String CL_ADDED_SWITCH_2 = "username"; |
29 static final String CL_ADDED_VALUE_2 = "bozo"; | 30 static final String CL_ADDED_VALUE_2 = "bozo"; |
30 | 31 |
31 @Override | 32 @Override |
32 public void setUp() throws Exception { | 33 public void setUp() throws Exception { |
33 CommandLine.reset(); | 34 CommandLine.reset(); |
34 } | 35 } |
35 | 36 |
36 void loadJni() { | 37 void loadJni() { |
37 assertFalse(CommandLine.getInstance().isNativeImplementation()); | 38 assertFalse(CommandLine.getInstance().isNativeImplementation()); |
38 getInstrumentation().runOnMainSync(new Runnable() { | 39 getInstrumentation().runOnMainSync(new Runnable() { |
39 @Override | 40 @Override |
40 public void run() { | 41 public void run() { |
41 ContentShellApplication.initializeApplicationParameters(); | 42 ContentShellApplication.initializeApplicationParameters(); |
42 LibraryLoader.ensureInitialized(); | 43 try { |
| 44 LibraryLoader.ensureInitialized(); |
| 45 } catch (ProcessInitException e) { |
| 46 throw new Error(e); |
| 47 } |
43 } | 48 } |
44 }); | 49 }); |
45 assertTrue(CommandLine.getInstance().isNativeImplementation()); | 50 assertTrue(CommandLine.getInstance().isNativeImplementation()); |
46 } | 51 } |
47 | 52 |
48 void checkInitSwitches() { | 53 void checkInitSwitches() { |
49 CommandLine cl = CommandLine.getInstance(); | 54 CommandLine cl = CommandLine.getInstance(); |
50 assertFalse(cl.hasSwitch("init_command")); | 55 assertFalse(cl.hasSwitch("init_command")); |
51 assertFalse(cl.hasSwitch("switch")); | 56 assertFalse(cl.hasSwitch("switch")); |
52 assertTrue(cl.hasSwitch("SWITCH")); | 57 assertTrue(cl.hasSwitch("SWITCH")); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 173 } |
169 | 174 |
170 @MediumTest | 175 @MediumTest |
171 @Feature({"Android-AppBase"}) | 176 @Feature({"Android-AppBase"}) |
172 public void testFileInitialization() { | 177 public void testFileInitialization() { |
173 CommandLine.initFromFile(ContentShellActivity.COMMAND_LINE_FILE); | 178 CommandLine.initFromFile(ContentShellActivity.COMMAND_LINE_FILE); |
174 loadJni(); | 179 loadJni(); |
175 checkSettingThenGetting(); | 180 checkSettingThenGetting(); |
176 } | 181 } |
177 } | 182 } |
OLD | NEW |