Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: apps/load_and_launch_browsertest.cc

Issue 15947007: Move application restart and relaunch code out of ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pafooey Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « apps/apps.gypi ('k') | apps/switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 11 #include "chrome/browser/extensions/extension_browsertest.h"
11 #include "chrome/browser/extensions/extension_test_message_listener.h" 12 #include "chrome/browser/extensions/extension_test_message_listener.h"
12 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 13 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
13 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
15 #include "content/public/test/test_launcher.h" 16 #include "content/public/test/test_launcher.h"
16 17
17 namespace extensions { 18 using extensions::PlatformAppBrowserTest;
19
20 namespace apps {
18 21
19 // TODO(jackhou): Enable this test once it works on OSX. It currently does not 22 // TODO(jackhou): Enable this test once it works on OSX. It currently does not
20 // work for the same reason --app-id doesn't. See http://crbug.com/148465 23 // work for the same reason --app-id doesn't. See http://crbug.com/148465
21 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
22 #define MAYBE_LoadAndLaunchAppChromeRunning \ 25 #define MAYBE_LoadAndLaunchAppChromeRunning \
23 DISABLED_LoadAndLaunchAppChromeRunning 26 DISABLED_LoadAndLaunchAppChromeRunning
24 #else 27 #else
25 #define MAYBE_LoadAndLaunchAppChromeRunning LoadAndLaunchAppChromeRunning 28 #define MAYBE_LoadAndLaunchAppChromeRunning LoadAndLaunchAppChromeRunning
26 #endif 29 #endif
27 30
28 // Case where Chrome is already running. 31 // Case where Chrome is already running.
29 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, 32 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
30 MAYBE_LoadAndLaunchAppChromeRunning) { 33 MAYBE_LoadAndLaunchAppChromeRunning) {
31 ExtensionTestMessageListener launched_listener("Launched", false); 34 ExtensionTestMessageListener launched_listener("Launched", false);
32 35
33 const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); 36 const CommandLine& cmdline = *CommandLine::ForCurrentProcess();
34 CommandLine new_cmdline(cmdline.GetProgram()); 37 CommandLine new_cmdline(cmdline.GetProgram());
35 38
36 const char* kSwitchNames[] = { 39 const char* kSwitchNames[] = {
37 switches::kUserDataDir, 40 switches::kUserDataDir,
38 }; 41 };
39 new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames)); 42 new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames));
40 43
41 base::FilePath app_path = test_data_dir_ 44 base::FilePath app_path = test_data_dir_
42 .AppendASCII("platform_apps") 45 .AppendASCII("platform_apps")
43 .AppendASCII("minimal"); 46 .AppendASCII("minimal");
44 47
45 new_cmdline.AppendSwitchNative(switches::kLoadAndLaunchApp, 48 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp,
46 app_path.value()); 49 app_path.value());
47 50
48 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); 51 new_cmdline.AppendSwitch(content::kLaunchAsBrowser);
49 base::ProcessHandle process; 52 base::ProcessHandle process;
50 base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process); 53 base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process);
51 ASSERT_NE(base::kNullProcessHandle, process); 54 ASSERT_NE(base::kNullProcessHandle, process);
52 55
53 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 56 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
54 ASSERT_TRUE(base::WaitForSingleProcess( 57 ASSERT_TRUE(base::WaitForSingleProcess(
55 process, TestTimeouts::action_timeout())); 58 process, TestTimeouts::action_timeout()));
56 } 59 }
57 60
58 namespace { 61 namespace {
59 62
60 // TestFixture that appends --load-and-launch-app before calling BrowserMain. 63 // TestFixture that appends --load-and-launch-app before calling BrowserMain.
61 class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest { 64 class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest {
62 protected: 65 protected:
63 PlatformAppLoadAndLaunchBrowserTest() {} 66 PlatformAppLoadAndLaunchBrowserTest() {}
64 67
65 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 68 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
66 PlatformAppBrowserTest::SetUpCommandLine(command_line); 69 PlatformAppBrowserTest::SetUpCommandLine(command_line);
67 app_path_ = test_data_dir_ 70 app_path_ = test_data_dir_
68 .AppendASCII("platform_apps") 71 .AppendASCII("platform_apps")
69 .AppendASCII("minimal"); 72 .AppendASCII("minimal");
70 command_line->AppendSwitchNative(switches::kLoadAndLaunchApp, 73 command_line->AppendSwitchNative(apps::kLoadAndLaunchApp,
71 app_path_.value()); 74 app_path_.value());
72 } 75 }
73 76
74 void LoadAndLaunchApp() { 77 void LoadAndLaunchApp() {
75 ExtensionTestMessageListener launched_listener("Launched", false); 78 ExtensionTestMessageListener launched_listener("Launched", false);
76 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 79 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
77 80
78 // Start an actual browser because we can't shut down with just an app 81 // Start an actual browser because we can't shut down with just an app
79 // window. 82 // window.
80 CreateBrowser(ProfileManager::GetDefaultProfile()); 83 CreateBrowser(ProfileManager::GetDefaultProfile());
(...skipping 16 matching lines...) Expand all
97 #define MAYBE_LoadAndLaunchAppChromeNotRunning \ 100 #define MAYBE_LoadAndLaunchAppChromeNotRunning \
98 LoadAndLaunchAppChromeNotRunning 101 LoadAndLaunchAppChromeNotRunning
99 #endif 102 #endif
100 103
101 // Case where Chrome is not running. 104 // Case where Chrome is not running.
102 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest, 105 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest,
103 MAYBE_LoadAndLaunchAppChromeNotRunning) { 106 MAYBE_LoadAndLaunchAppChromeNotRunning) {
104 LoadAndLaunchApp(); 107 LoadAndLaunchApp();
105 } 108 }
106 109
107 } // namespace extensions 110 } // namespace apps
OLDNEW
« no previous file with comments | « apps/apps.gypi ('k') | apps/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698