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