| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/panels/panel_browser_window_cocoa.h" | 5 #import "chrome/browser/ui/panels/panel_browser_window_cocoa.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@""]); | 307 scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@""]); |
| 308 NSMenuItem* close_tab_menu_item = CreateMenuItem(menu, IDC_CLOSE_TAB); | 308 NSMenuItem* close_tab_menu_item = CreateMenuItem(menu, IDC_CLOSE_TAB); |
| 309 NSMenuItem* close_window_menu_item = CreateMenuItem(menu, IDC_CLOSE_WINDOW); | 309 NSMenuItem* close_window_menu_item = CreateMenuItem(menu, IDC_CLOSE_WINDOW); |
| 310 NSMenuItem* find_menu_item = CreateMenuItem(menu, IDC_FIND); | 310 NSMenuItem* find_menu_item = CreateMenuItem(menu, IDC_FIND); |
| 311 NSMenuItem* find_previous_menu_item = CreateMenuItem(menu, IDC_FIND_PREVIOUS); | 311 NSMenuItem* find_previous_menu_item = CreateMenuItem(menu, IDC_FIND_PREVIOUS); |
| 312 NSMenuItem* find_next_menu_item = CreateMenuItem(menu, IDC_FIND_NEXT); | 312 NSMenuItem* find_next_menu_item = CreateMenuItem(menu, IDC_FIND_NEXT); |
| 313 NSMenuItem* fullscreen_menu_item = CreateMenuItem(menu, IDC_FULLSCREEN); | 313 NSMenuItem* fullscreen_menu_item = CreateMenuItem(menu, IDC_FULLSCREEN); |
| 314 NSMenuItem* presentation_menu_item = | 314 NSMenuItem* presentation_menu_item = |
| 315 CreateMenuItem(menu, IDC_PRESENTATION_MODE); | 315 CreateMenuItem(menu, IDC_PRESENTATION_MODE); |
| 316 NSMenuItem* bookmarks_menu_item = CreateMenuItem(menu, IDC_SYNC_BOOKMARKS); | 316 NSMenuItem* sync_menu_item = CreateMenuItem(menu, IDC_SHOW_SYNC_SETUP); |
| 317 | 317 |
| 318 PanelBrowserWindowCocoa* native_window = | 318 PanelBrowserWindowCocoa* native_window = |
| 319 static_cast<PanelBrowserWindowCocoa*>(panel->native_panel()); | 319 static_cast<PanelBrowserWindowCocoa*>(panel->native_panel()); |
| 320 PanelWindowControllerCocoa* panel_controller = native_window->controller_; | 320 PanelWindowControllerCocoa* panel_controller = native_window->controller_; |
| 321 for (NSMenuItem *item in [menu itemArray]) | 321 for (NSMenuItem *item in [menu itemArray]) |
| 322 [item setTarget:panel_controller]; | 322 [item setTarget:panel_controller]; |
| 323 | 323 |
| 324 [menu update]; // Trigger validation of menu items. | 324 [menu update]; // Trigger validation of menu items. |
| 325 EXPECT_FALSE([close_tab_menu_item isEnabled]); | 325 EXPECT_FALSE([close_tab_menu_item isEnabled]); |
| 326 EXPECT_TRUE([close_window_menu_item isEnabled]); | 326 EXPECT_TRUE([close_window_menu_item isEnabled]); |
| 327 EXPECT_TRUE([find_menu_item isEnabled]); | 327 EXPECT_TRUE([find_menu_item isEnabled]); |
| 328 EXPECT_TRUE([find_previous_menu_item isEnabled]); | 328 EXPECT_TRUE([find_previous_menu_item isEnabled]); |
| 329 EXPECT_TRUE([find_next_menu_item isEnabled]); | 329 EXPECT_TRUE([find_next_menu_item isEnabled]); |
| 330 EXPECT_FALSE([fullscreen_menu_item isEnabled]); | 330 EXPECT_FALSE([fullscreen_menu_item isEnabled]); |
| 331 EXPECT_FALSE([presentation_menu_item isEnabled]); | 331 EXPECT_FALSE([presentation_menu_item isEnabled]); |
| 332 EXPECT_FALSE([bookmarks_menu_item isEnabled]); | 332 EXPECT_FALSE([sync_menu_item isEnabled]); |
| 333 | 333 |
| 334 ClosePanelAndWait(panel->browser()); | 334 ClosePanelAndWait(panel->browser()); |
| 335 } | 335 } |
| 336 | 336 |
| 337 TEST_F(PanelBrowserWindowCocoaTest, KeyEvent) { | 337 TEST_F(PanelBrowserWindowCocoaTest, KeyEvent) { |
| 338 Panel* panel = CreateTestPanel("Test Panel"); | 338 Panel* panel = CreateTestPanel("Test Panel"); |
| 339 NSEvent* event = [NSEvent keyEventWithType:NSKeyDown | 339 NSEvent* event = [NSEvent keyEventWithType:NSKeyDown |
| 340 location:NSZeroPoint | 340 location:NSZeroPoint |
| 341 modifierFlags:NSControlKeyMask | 341 modifierFlags:NSControlKeyMask |
| 342 timestamp:0.0 | 342 timestamp:0.0 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 NSWindow* frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; | 400 NSWindow* frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; |
| 401 EXPECT_NSEQ(frontmostWindow, [native_window->controller_ window]); | 401 EXPECT_NSEQ(frontmostWindow, [native_window->controller_ window]); |
| 402 | 402 |
| 403 native_window2->ActivatePanel(); | 403 native_window2->ActivatePanel(); |
| 404 frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; | 404 frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; |
| 405 EXPECT_NSEQ(frontmostWindow, [native_window2->controller_ window]); | 405 EXPECT_NSEQ(frontmostWindow, [native_window2->controller_ window]); |
| 406 | 406 |
| 407 ClosePanelAndWait(panel->browser()); | 407 ClosePanelAndWait(panel->browser()); |
| 408 ClosePanelAndWait(panel2->browser()); | 408 ClosePanelAndWait(panel2->browser()); |
| 409 } | 409 } |
| OLD | NEW |