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

Side by Side Diff: chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm

Issue 1268293002: [MacViews] Fix AccessiblePaneViewTest.SetPaneFocusAndRestore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove dependent patch. Created 5 years, 4 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
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 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" 5 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
11 #import "base/mac/scoped_nsobject.h" 11 #import "base/mac/scoped_nsobject.h"
12 #import "base/mac/scoped_objc_class_swizzler.h" 12 #import "base/mac/scoped_objc_class_swizzler.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/apps/app_browsertest_util.h" 15 #include "chrome/browser/apps/app_browsertest_util.h"
16 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" 16 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/launch_util.h" 18 #include "chrome/browser/extensions/launch_util.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser_iterator.h" 20 #include "chrome/browser/ui/browser_iterator.h"
21 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
22 #import "chrome/browser/ui/test/scoped_fake_nswindow_main_status.h"
23 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
24 #include "extensions/browser/app_window/app_window_registry.h" 23 #include "extensions/browser/app_window/app_window_registry.h"
25 #include "extensions/browser/app_window/native_app_window.h" 24 #include "extensions/browser/app_window/native_app_window.h"
26 #include "extensions/browser/uninstall_reason.h" 25 #include "extensions/browser/uninstall_reason.h"
27 #include "extensions/common/extension.h" 26 #include "extensions/common/extension.h"
28 #include "extensions/test/extension_test_message_listener.h" 27 #include "extensions/test/extension_test_message_listener.h"
28 #import "ui/base/test/scoped_fake_nswindow_focus.h"
29 29
30 namespace { 30 namespace {
31 31
32 class AppShimMenuControllerBrowserTest 32 class AppShimMenuControllerBrowserTest
33 : public extensions::PlatformAppBrowserTest { 33 : public extensions::PlatformAppBrowserTest {
34 protected: 34 protected:
35 // The apps that can be installed and launched by SetUpApps(). 35 // The apps that can be installed and launched by SetUpApps().
36 enum AvailableApps { PACKAGED_1 = 0x1, PACKAGED_2 = 0x2, HOSTED = 0x4 }; 36 enum AvailableApps { PACKAGED_1 = 0x1, PACKAGED_2 = 0x2, HOSTED = 0x4 };
37 37
38 AppShimMenuControllerBrowserTest() 38 AppShimMenuControllerBrowserTest()
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 179 }
180 180
181 // Test that closing windows without main status do not update the menu. 181 // Test that closing windows without main status do not update the menu.
182 IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest, 182 IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
183 ClosingBackgroundWindowLeavesMenuBar) { 183 ClosingBackgroundWindowLeavesMenuBar) {
184 // Start with app1 active. 184 // Start with app1 active.
185 SetUpApps(PACKAGED_1); 185 SetUpApps(PACKAGED_1);
186 extensions::AppWindow* app_1_app_window = FirstWindowForApp(app_1_); 186 extensions::AppWindow* app_1_app_window = FirstWindowForApp(app_1_);
187 187
188 { 188 {
189 ScopedFakeNSWindowMainStatus app_1_is_main( 189 ui::test::ScopedFakeNSWindowMainStatus app_1_is_main(
190 app_1_app_window->GetNativeWindow()); 190 app_1_app_window->GetNativeWindow());
191 [[NSNotificationCenter defaultCenter] 191 [[NSNotificationCenter defaultCenter]
192 postNotificationName:NSWindowDidBecomeMainNotification 192 postNotificationName:NSWindowDidBecomeMainNotification
193 object:app_1_app_window->GetNativeWindow()]; 193 object:app_1_app_window->GetNativeWindow()];
194 CheckHasAppMenus(app_1_); 194 CheckHasAppMenus(app_1_);
195 195
196 // Closing a background window without focusing it should not change menus. 196 // Closing a background window without focusing it should not change menus.
197 BrowserWindow* chrome_window = chrome::BrowserIterator()->window(); 197 BrowserWindow* chrome_window = chrome::BrowserIterator()->window();
198 chrome_window->Close(); 198 chrome_window->Close();
199 [[NSNotificationCenter defaultCenter] 199 [[NSNotificationCenter defaultCenter]
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest, 246 IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
247 ExtensionUninstallUpdatesMenuBar) { 247 ExtensionUninstallUpdatesMenuBar) {
248 SetUpApps(PACKAGED_1 | PACKAGED_2); 248 SetUpApps(PACKAGED_1 | PACKAGED_2);
249 249
250 FirstWindowForApp(app_2_)->GetBaseWindow()->Close(); 250 FirstWindowForApp(app_2_)->GetBaseWindow()->Close();
251 chrome::BrowserIterator()->window()->Close(); 251 chrome::BrowserIterator()->window()->Close();
252 NSWindow* app_1_window = FirstWindowForApp(app_1_)->GetNativeWindow(); 252 NSWindow* app_1_window = FirstWindowForApp(app_1_)->GetNativeWindow();
253 [[NSNotificationCenter defaultCenter] 253 [[NSNotificationCenter defaultCenter]
254 postNotificationName:NSWindowDidBecomeMainNotification 254 postNotificationName:NSWindowDidBecomeMainNotification
255 object:app_1_window]; 255 object:app_1_window];
256 ScopedFakeNSWindowMainStatus app_1_is_main(app_1_window); 256 ui::test::ScopedFakeNSWindowMainStatus app_1_is_main(app_1_window);
257 257
258 CheckHasAppMenus(app_1_); 258 CheckHasAppMenus(app_1_);
259 ExtensionService::UninstallExtensionHelper( 259 ExtensionService::UninstallExtensionHelper(
260 extension_service(), 260 extension_service(),
261 app_1_->id(), 261 app_1_->id(),
262 extensions::UNINSTALL_REASON_FOR_TESTING); 262 extensions::UNINSTALL_REASON_FOR_TESTING);
263 263
264 // OSX will send NSWindowWillResignMainNotification when a main window is 264 // OSX will send NSWindowWillResignMainNotification when a main window is
265 // closed. 265 // closed.
266 [[NSNotificationCenter defaultCenter] 266 [[NSNotificationCenter defaultCenter]
267 postNotificationName:NSWindowDidResignMainNotification 267 postNotificationName:NSWindowDidResignMainNotification
268 object:app_1_window]; 268 object:app_1_window];
269 CheckNoAppMenus(); 269 CheckNoAppMenus();
270 } 270 }
271 271
272 } // namespace 272 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698