| 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/process/launch.h" | 10 #include "base/process/launch.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, | 56 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, |
| 57 app_path.value()); | 57 app_path.value()); |
| 58 | 58 |
| 59 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); | 59 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); |
| 60 base::Process process = | 60 base::Process process = |
| 61 base::LaunchProcess(new_cmdline, base::LaunchOptionsForTest()); | 61 base::LaunchProcess(new_cmdline, base::LaunchOptionsForTest()); |
| 62 ASSERT_TRUE(process.IsValid()); | 62 ASSERT_TRUE(process.IsValid()); |
| 63 | 63 |
| 64 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 64 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 65 ASSERT_TRUE(base::WaitForSingleProcess(process.Handle(), | 65 int exit_code; |
| 66 TestTimeouts::action_timeout())); | 66 ASSERT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_timeout(), |
| 67 &exit_code)); |
| 67 } | 68 } |
| 68 | 69 |
| 69 // TODO(jackhou): Enable this test once it works on OSX. It currently does not | 70 // TODO(jackhou): Enable this test once it works on OSX. It currently does not |
| 70 // work for the same reason --app-id doesn't. See http://crbug.com/148465 | 71 // work for the same reason --app-id doesn't. See http://crbug.com/148465 |
| 71 #if defined(OS_MACOSX) | 72 #if defined(OS_MACOSX) |
| 72 #define MAYBE_LoadAndLaunchAppWithFile DISABLED_LoadAndLaunchAppWithFile | 73 #define MAYBE_LoadAndLaunchAppWithFile DISABLED_LoadAndLaunchAppWithFile |
| 73 #else | 74 #else |
| 74 #define MAYBE_LoadAndLaunchAppWithFile LoadAndLaunchAppWithFile | 75 #define MAYBE_LoadAndLaunchAppWithFile LoadAndLaunchAppWithFile |
| 75 #endif | 76 #endif |
| 76 | 77 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 95 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, | 96 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, |
| 96 app_path.value()); | 97 app_path.value()); |
| 97 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); | 98 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); |
| 98 new_cmdline.AppendArgPath(test_file_path); | 99 new_cmdline.AppendArgPath(test_file_path); |
| 99 | 100 |
| 100 base::Process process = | 101 base::Process process = |
| 101 base::LaunchProcess(new_cmdline, base::LaunchOptionsForTest()); | 102 base::LaunchProcess(new_cmdline, base::LaunchOptionsForTest()); |
| 102 ASSERT_TRUE(process.IsValid()); | 103 ASSERT_TRUE(process.IsValid()); |
| 103 | 104 |
| 104 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 105 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 105 ASSERT_TRUE(base::WaitForSingleProcess(process.Handle(), | 106 int exit_code; |
| 106 TestTimeouts::action_timeout())); | 107 ASSERT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_timeout(), |
| 108 &exit_code)); |
| 107 } | 109 } |
| 108 | 110 |
| 109 namespace { | 111 namespace { |
| 110 | 112 |
| 111 // TestFixture that appends --load-and-launch-app before calling BrowserMain. | 113 // TestFixture that appends --load-and-launch-app before calling BrowserMain. |
| 112 class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest { | 114 class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest { |
| 113 protected: | 115 protected: |
| 114 PlatformAppLoadAndLaunchBrowserTest() {} | 116 PlatformAppLoadAndLaunchBrowserTest() {} |
| 115 | 117 |
| 116 void SetUpCommandLine(base::CommandLine* command_line) override { | 118 void SetUpCommandLine(base::CommandLine* command_line) override { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 LoadAndLaunchAppChromeNotRunning | 152 LoadAndLaunchAppChromeNotRunning |
| 151 #endif | 153 #endif |
| 152 | 154 |
| 153 // Case where Chrome is not running. | 155 // Case where Chrome is not running. |
| 154 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest, | 156 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest, |
| 155 MAYBE_LoadAndLaunchAppChromeNotRunning) { | 157 MAYBE_LoadAndLaunchAppChromeNotRunning) { |
| 156 LoadAndLaunchApp(); | 158 LoadAndLaunchApp(); |
| 157 } | 159 } |
| 158 | 160 |
| 159 } // namespace apps | 161 } // namespace apps |
| OLD | NEW |