OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Tests for the --load-and-launch-app switch. | 5 // Tests for the --load-and-launch-app switch. |
6 // The two cases are when chrome is running and another process uses the switch | 6 // The two cases are when chrome is running and another process uses the switch |
7 // and when chrome is started from scratch. | 7 // and when chrome is started from scratch. |
8 | 8 |
9 #include "apps/switches.h" | 9 #include "apps/switches.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); | 51 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); |
52 base::ProcessHandle process; | 52 base::ProcessHandle process; |
53 base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process); | 53 base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process); |
54 ASSERT_NE(base::kNullProcessHandle, process); | 54 ASSERT_NE(base::kNullProcessHandle, process); |
55 | 55 |
56 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 56 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
57 ASSERT_TRUE(base::WaitForSingleProcess( | 57 ASSERT_TRUE(base::WaitForSingleProcess( |
58 process, TestTimeouts::action_timeout())); | 58 process, TestTimeouts::action_timeout())); |
59 } | 59 } |
60 | 60 |
| 61 // TODO(jackhou): Enable this test once it works on OSX. It currently does not |
| 62 // work for the same reason --app-id doesn't. See http://crbug.com/148465 |
| 63 #if defined(OS_MACOSX) |
| 64 #define MAYBE_LoadAndLaunchAppWithFile DISABLED_LoadAndLaunchAppWithFile |
| 65 #else |
| 66 #define MAYBE_LoadAndLaunchAppWithFile LoadAndLaunchAppWithFile |
| 67 #endif |
| 68 |
| 69 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, |
| 70 MAYBE_LoadAndLaunchAppWithFile) { |
| 71 ExtensionTestMessageListener launched_listener("Launched", false); |
| 72 |
| 73 const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); |
| 74 CommandLine new_cmdline(cmdline.GetProgram()); |
| 75 |
| 76 const char* kSwitchNames[] = { |
| 77 switches::kUserDataDir, |
| 78 }; |
| 79 new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames)); |
| 80 |
| 81 base::FilePath app_path = test_data_dir_ |
| 82 .AppendASCII("platform_apps") |
| 83 .AppendASCII("load_and_launch_file"); |
| 84 |
| 85 base::FilePath test_file_path = test_data_dir_ |
| 86 .AppendASCII("platform_apps") |
| 87 .AppendASCII("launch_files") |
| 88 .AppendASCII("test.txt"); |
| 89 |
| 90 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, |
| 91 app_path.value()); |
| 92 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); |
| 93 new_cmdline.AppendArgPath(test_file_path); |
| 94 |
| 95 base::ProcessHandle process; |
| 96 base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process); |
| 97 ASSERT_NE(base::kNullProcessHandle, process); |
| 98 |
| 99 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 100 ASSERT_TRUE(base::WaitForSingleProcess( |
| 101 process, TestTimeouts::action_timeout())); |
| 102 } |
| 103 |
61 namespace { | 104 namespace { |
62 | 105 |
63 // TestFixture that appends --load-and-launch-app before calling BrowserMain. | 106 // TestFixture that appends --load-and-launch-app before calling BrowserMain. |
64 class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest { | 107 class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest { |
65 protected: | 108 protected: |
66 PlatformAppLoadAndLaunchBrowserTest() {} | 109 PlatformAppLoadAndLaunchBrowserTest() {} |
67 | 110 |
68 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 111 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
69 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 112 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
70 app_path_ = test_data_dir_ | 113 app_path_ = test_data_dir_ |
(...skipping 30 matching lines...) Expand all Loading... |
101 LoadAndLaunchAppChromeNotRunning | 144 LoadAndLaunchAppChromeNotRunning |
102 #endif | 145 #endif |
103 | 146 |
104 // Case where Chrome is not running. | 147 // Case where Chrome is not running. |
105 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest, | 148 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest, |
106 MAYBE_LoadAndLaunchAppChromeNotRunning) { | 149 MAYBE_LoadAndLaunchAppChromeNotRunning) { |
107 LoadAndLaunchApp(); | 150 LoadAndLaunchApp(); |
108 } | 151 } |
109 | 152 |
110 } // namespace apps | 153 } // namespace apps |
OLD | NEW |