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 behavior when quitting apps with app shims. | 5 // Tests behavior when quitting apps with app shims. |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "apps/switches.h" | 10 #include "apps/switches.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 class FakeHost : public apps::AppShimHandler::Host { | 30 class FakeHost : public apps::AppShimHandler::Host { |
31 public: | 31 public: |
32 FakeHost(const base::FilePath& profile_path, | 32 FakeHost(const base::FilePath& profile_path, |
33 const std::string& app_id, | 33 const std::string& app_id, |
34 ExtensionAppShimHandler* handler) | 34 ExtensionAppShimHandler* handler) |
35 : profile_path_(profile_path), | 35 : profile_path_(profile_path), |
36 app_id_(app_id), | 36 app_id_(app_id), |
37 handler_(handler) {} | 37 handler_(handler) {} |
38 | 38 |
39 virtual void OnAppLaunchComplete(AppShimLaunchResult result) OVERRIDE {} | 39 virtual void OnAppLaunchComplete(AppShimLaunchResult result) override {} |
40 virtual void OnAppClosed() OVERRIDE { | 40 virtual void OnAppClosed() override { |
41 handler_->OnShimClose(this); | 41 handler_->OnShimClose(this); |
42 } | 42 } |
43 virtual void OnAppHide() OVERRIDE {} | 43 virtual void OnAppHide() override {} |
44 virtual void OnAppRequestUserAttention(AppShimAttentionType type) OVERRIDE {} | 44 virtual void OnAppRequestUserAttention(AppShimAttentionType type) override {} |
45 virtual base::FilePath GetProfilePath() const OVERRIDE { | 45 virtual base::FilePath GetProfilePath() const override { |
46 return profile_path_; | 46 return profile_path_; |
47 } | 47 } |
48 virtual std::string GetAppId() const OVERRIDE { return app_id_; } | 48 virtual std::string GetAppId() const override { return app_id_; } |
49 | 49 |
50 private: | 50 private: |
51 base::FilePath profile_path_; | 51 base::FilePath profile_path_; |
52 std::string app_id_; | 52 std::string app_id_; |
53 ExtensionAppShimHandler* handler_; | 53 ExtensionAppShimHandler* handler_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(FakeHost); | 55 DISALLOW_COPY_AND_ASSIGN(FakeHost); |
56 }; | 56 }; |
57 | 57 |
58 // Starts an app without a browser window using --load_and_launch_app and | 58 // Starts an app without a browser window using --load_and_launch_app and |
(...skipping 23 matching lines...) Expand all Loading... |
82 APP_SHIM_LAUNCH_REGISTER_ONLY, | 82 APP_SHIM_LAUNCH_REGISTER_ONLY, |
83 std::vector<base::FilePath>()); | 83 std::vector<base::FilePath>()); |
84 EXPECT_EQ(host_.get(), handler_->FindHost(profile(), extension_id_)); | 84 EXPECT_EQ(host_.get(), handler_->FindHost(profile(), extension_id_)); |
85 | 85 |
86 // Focus the app window. | 86 // Focus the app window. |
87 NSWindow* window = [[NSApp windows] objectAtIndex:0]; | 87 NSWindow* window = [[NSApp windows] objectAtIndex:0]; |
88 EXPECT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); | 88 EXPECT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); |
89 content::RunAllPendingInMessageLoop(); | 89 content::RunAllPendingInMessageLoop(); |
90 } | 90 } |
91 | 91 |
92 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 92 virtual void SetUpCommandLine(CommandLine* command_line) override { |
93 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 93 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
94 // Simulate an app shim initiated launch, i.e. launch app but not browser. | 94 // Simulate an app shim initiated launch, i.e. launch app but not browser. |
95 app_path_ = test_data_dir_ | 95 app_path_ = test_data_dir_ |
96 .AppendASCII("platform_apps") | 96 .AppendASCII("platform_apps") |
97 .AppendASCII("minimal"); | 97 .AppendASCII("minimal"); |
98 command_line->AppendSwitchNative(apps::kLoadAndLaunchApp, | 98 command_line->AppendSwitchNative(apps::kLoadAndLaunchApp, |
99 app_path_.value()); | 99 app_path_.value()); |
100 command_line->AppendSwitch(switches::kSilentLaunch); | 100 command_line->AppendSwitch(switches::kSilentLaunch); |
101 } | 101 } |
102 | 102 |
(...skipping 20 matching lines...) Expand all Loading... |
123 atStart:NO]; | 123 atStart:NO]; |
124 | 124 |
125 // This will time out if the event above does not terminate Chrome. | 125 // This will time out if the event above does not terminate Chrome. |
126 content::RunMessageLoop(); | 126 content::RunMessageLoop(); |
127 | 127 |
128 EXPECT_FALSE(handler_->FindHost(profile(), extension_id_)); | 128 EXPECT_FALSE(handler_->FindHost(profile(), extension_id_)); |
129 EXPECT_TRUE(browser_shutdown::IsTryingToQuit()); | 129 EXPECT_TRUE(browser_shutdown::IsTryingToQuit()); |
130 } | 130 } |
131 | 131 |
132 } // namespace apps | 132 } // namespace apps |
OLD | NEW |