| 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" |
| 11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
| 12 #include "chrome/browser/apps/app_browsertest_util.h" | 12 #include "chrome/browser/apps/app_browsertest_util.h" |
| 13 #include "chrome/browser/extensions/extension_browsertest.h" | 13 #include "chrome/browser/extensions/extension_browsertest.h" |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/test/test_launcher.h" | 17 #include "content/public/test/test_launcher.h" |
| 17 #include "extensions/test/extension_test_message_listener.h" | 18 #include "extensions/test/extension_test_message_listener.h" |
| 18 | 19 |
| 19 using extensions::PlatformAppBrowserTest; | 20 using extensions::PlatformAppBrowserTest; |
| 20 | 21 |
| 21 namespace apps { | 22 namespace apps { |
| 22 | 23 |
| 24 namespace { |
| 25 |
| 26 const char* kSwitchesToCopy[] = { |
| 27 switches::kUserDataDir, |
| 28 switches::kNoSandbox, |
| 29 }; |
| 30 |
| 31 } // namespace |
| 32 |
| 23 // TODO(jackhou): Enable this test once it works on OSX. It currently does not | 33 // TODO(jackhou): Enable this test once it works on OSX. It currently does not |
| 24 // work for the same reason --app-id doesn't. See http://crbug.com/148465 | 34 // work for the same reason --app-id doesn't. See http://crbug.com/148465 |
| 25 #if defined(OS_MACOSX) | 35 #if defined(OS_MACOSX) |
| 26 #define MAYBE_LoadAndLaunchAppChromeRunning \ | 36 #define MAYBE_LoadAndLaunchAppChromeRunning \ |
| 27 DISABLED_LoadAndLaunchAppChromeRunning | 37 DISABLED_LoadAndLaunchAppChromeRunning |
| 28 #else | 38 #else |
| 29 #define MAYBE_LoadAndLaunchAppChromeRunning LoadAndLaunchAppChromeRunning | 39 #define MAYBE_LoadAndLaunchAppChromeRunning LoadAndLaunchAppChromeRunning |
| 30 #endif | 40 #endif |
| 31 | 41 |
| 32 // Case where Chrome is already running. | 42 // Case where Chrome is already running. |
| 33 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, | 43 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, |
| 34 MAYBE_LoadAndLaunchAppChromeRunning) { | 44 MAYBE_LoadAndLaunchAppChromeRunning) { |
| 35 ExtensionTestMessageListener launched_listener("Launched", false); | 45 ExtensionTestMessageListener launched_listener("Launched", false); |
| 36 | 46 |
| 37 const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); | 47 const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); |
| 38 base::CommandLine new_cmdline(cmdline.GetProgram()); | 48 base::CommandLine new_cmdline(cmdline.GetProgram()); |
| 39 | 49 new_cmdline.CopySwitchesFrom(cmdline, kSwitchesToCopy, |
| 40 const char* kSwitchNames[] = { | 50 arraysize(kSwitchesToCopy)); |
| 41 switches::kUserDataDir, | |
| 42 }; | |
| 43 new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames)); | |
| 44 | 51 |
| 45 base::FilePath app_path = test_data_dir_ | 52 base::FilePath app_path = test_data_dir_ |
| 46 .AppendASCII("platform_apps") | 53 .AppendASCII("platform_apps") |
| 47 .AppendASCII("minimal"); | 54 .AppendASCII("minimal"); |
| 48 | 55 |
| 49 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, | 56 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, |
| 50 app_path.value()); | 57 app_path.value()); |
| 51 | 58 |
| 52 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); | 59 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); |
| 53 base::Process process = | 60 base::Process process = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 66 #else | 73 #else |
| 67 #define MAYBE_LoadAndLaunchAppWithFile LoadAndLaunchAppWithFile | 74 #define MAYBE_LoadAndLaunchAppWithFile LoadAndLaunchAppWithFile |
| 68 #endif | 75 #endif |
| 69 | 76 |
| 70 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, | 77 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, |
| 71 MAYBE_LoadAndLaunchAppWithFile) { | 78 MAYBE_LoadAndLaunchAppWithFile) { |
| 72 ExtensionTestMessageListener launched_listener("Launched", false); | 79 ExtensionTestMessageListener launched_listener("Launched", false); |
| 73 | 80 |
| 74 const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); | 81 const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); |
| 75 base::CommandLine new_cmdline(cmdline.GetProgram()); | 82 base::CommandLine new_cmdline(cmdline.GetProgram()); |
| 76 | 83 new_cmdline.CopySwitchesFrom(cmdline, kSwitchesToCopy, |
| 77 const char* kSwitchNames[] = { | 84 arraysize(kSwitchesToCopy)); |
| 78 switches::kUserDataDir, | |
| 79 }; | |
| 80 new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames)); | |
| 81 | 85 |
| 82 base::FilePath app_path = test_data_dir_ | 86 base::FilePath app_path = test_data_dir_ |
| 83 .AppendASCII("platform_apps") | 87 .AppendASCII("platform_apps") |
| 84 .AppendASCII("load_and_launch_file"); | 88 .AppendASCII("load_and_launch_file"); |
| 85 | 89 |
| 86 base::FilePath test_file_path = test_data_dir_ | 90 base::FilePath test_file_path = test_data_dir_ |
| 87 .AppendASCII("platform_apps") | 91 .AppendASCII("platform_apps") |
| 88 .AppendASCII("launch_files") | 92 .AppendASCII("launch_files") |
| 89 .AppendASCII("test.txt"); | 93 .AppendASCII("test.txt"); |
| 90 | 94 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 LoadAndLaunchAppChromeNotRunning | 150 LoadAndLaunchAppChromeNotRunning |
| 147 #endif | 151 #endif |
| 148 | 152 |
| 149 // Case where Chrome is not running. | 153 // Case where Chrome is not running. |
| 150 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest, | 154 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest, |
| 151 MAYBE_LoadAndLaunchAppChromeNotRunning) { | 155 MAYBE_LoadAndLaunchAppChromeNotRunning) { |
| 152 LoadAndLaunchApp(); | 156 LoadAndLaunchApp(); |
| 153 } | 157 } |
| 154 | 158 |
| 155 } // namespace apps | 159 } // namespace apps |
| OLD | NEW |