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

Side by Side Diff: chrome/browser/extensions/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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Tests for the --load-and-launch-app switch.
6 // The two cases are when chrome is running and another process uses the switch
7 // and when chrome is started from scratch.
8
9 #include "base/test/test_timeouts.h"
10 #include "chrome/browser/extensions/extension_browsertest.h"
11 #include "chrome/browser/extensions/extension_test_message_listener.h"
12 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/chrome_switches.h"
15 #include "content/public/test/test_launcher.h"
16
17 namespace extensions {
18
19 // 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
21 #if defined(OS_MACOSX)
22 #define MAYBE_LoadAndLaunchAppChromeRunning \
23 DISABLED_LoadAndLaunchAppChromeRunning
24 #else
25 #define MAYBE_LoadAndLaunchAppChromeRunning LoadAndLaunchAppChromeRunning
26 #endif
27
28 // Case where Chrome is already running.
29 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
30 MAYBE_LoadAndLaunchAppChromeRunning) {
31 ExtensionTestMessageListener launched_listener("Launched", false);
32
33 const CommandLine& cmdline = *CommandLine::ForCurrentProcess();
34 CommandLine new_cmdline(cmdline.GetProgram());
35
36 const char* kSwitchNames[] = {
37 switches::kUserDataDir,
38 };
39 new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames));
40
41 base::FilePath app_path = test_data_dir_
42 .AppendASCII("platform_apps")
43 .AppendASCII("minimal");
44
45 new_cmdline.AppendSwitchNative(switches::kLoadAndLaunchApp,
46 app_path.value());
47
48 new_cmdline.AppendSwitch(content::kLaunchAsBrowser);
49 base::ProcessHandle process;
50 base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process);
51 ASSERT_NE(base::kNullProcessHandle, process);
52
53 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
54 ASSERT_TRUE(base::WaitForSingleProcess(
55 process, TestTimeouts::action_timeout()));
56 }
57
58 namespace {
59
60 // TestFixture that appends --load-and-launch-app before calling BrowserMain.
61 class PlatformAppLoadAndLaunchBrowserTest : public PlatformAppBrowserTest {
62 protected:
63 PlatformAppLoadAndLaunchBrowserTest() {}
64
65 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
66 PlatformAppBrowserTest::SetUpCommandLine(command_line);
67 app_path_ = test_data_dir_
68 .AppendASCII("platform_apps")
69 .AppendASCII("minimal");
70 command_line->AppendSwitchNative(switches::kLoadAndLaunchApp,
71 app_path_.value());
72 }
73
74 void LoadAndLaunchApp() {
75 ExtensionTestMessageListener launched_listener("Launched", false);
76 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
77
78 // Start an actual browser because we can't shut down with just an app
79 // window.
80 CreateBrowser(ProfileManager::GetDefaultProfile());
81 }
82
83 private:
84 base::FilePath app_path_;
85
86 DISALLOW_COPY_AND_ASSIGN(PlatformAppLoadAndLaunchBrowserTest);
87 };
88
89 } // namespace
90
91
92 // TODO(jackhou): Make this test not flaky on Vista. See http://crbug.com/176897
93 #if defined(OS_WIN)
94 #define MAYBE_LoadAndLaunchAppChromeNotRunning \
95 DISABLED_LoadAndLaunchAppChromeNotRunning
96 #else
97 #define MAYBE_LoadAndLaunchAppChromeNotRunning \
98 LoadAndLaunchAppChromeNotRunning
99 #endif
100
101 // Case where Chrome is not running.
102 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest,
103 MAYBE_LoadAndLaunchAppChromeNotRunning) {
104 LoadAndLaunchApp();
105 }
106
107 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_system.cc ('k') | chrome/browser/extensions/platform_app_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698