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

Side by Side Diff: chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm

Issue 10807047: Create content\public\test\test_utils.h to hold common test classes that are used by unit and brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
11 #include "base/debug/debugger.h" 11 #include "base/debug/debugger.h"
12 #include "base/mac/scoped_nsautorelease_pool.h" 12 #include "base/mac/scoped_nsautorelease_pool.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/sys_string_conversions.h" 14 #include "base/sys_string_conversions.h"
15 #include "chrome/app/chrome_command_ids.h" // IDC_* 15 #include "chrome/app/chrome_command_ids.h" // IDC_*
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_list.h" 17 #include "chrome/browser/ui/browser_list.h"
18 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 18 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
19 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 19 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
20 #import "chrome/browser/ui/cocoa/run_loop_testing.h" 20 #import "chrome/browser/ui/cocoa/run_loop_testing.h"
21 #include "chrome/browser/ui/panels/panel.h" 21 #include "chrome/browser/ui/panels/panel.h"
22 #include "chrome/browser/ui/panels/panel_browser_window.h" 22 #include "chrome/browser/ui/panels/panel_browser_window.h"
23 #include "chrome/browser/ui/panels/panel_manager.h" 23 #include "chrome/browser/ui/panels/panel_manager.h"
24 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" 24 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
25 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" 25 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
26 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/test/base/ui_test_utils.h" 28 #include "content/public/test/test_utils.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 #include "testing/gtest_mac.h" 30 #include "testing/gtest_mac.h"
31 31
32 class PanelAnimatedBoundsObserver : 32 class PanelAnimatedBoundsObserver :
33 public ui_test_utils::WindowedNotificationObserver { 33 public content::WindowedNotificationObserver {
34 public: 34 public:
35 PanelAnimatedBoundsObserver(Panel* panel) 35 PanelAnimatedBoundsObserver(Panel* panel)
36 : ui_test_utils::WindowedNotificationObserver( 36 : content::WindowedNotificationObserver(
37 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 37 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
38 content::Source<Panel>(panel)) { } 38 content::Source<Panel>(panel)) { }
39 virtual ~PanelAnimatedBoundsObserver() { } 39 virtual ~PanelAnimatedBoundsObserver() { }
40 }; 40 };
41 41
42 // Main test class. 42 // Main test class.
43 class PanelBrowserWindowCocoaTest : public CocoaProfileTest { 43 class PanelBrowserWindowCocoaTest : public CocoaProfileTest {
44 public: 44 public:
45 virtual void SetUp() { 45 virtual void SetUp() {
46 CocoaProfileTest::SetUp(); 46 CocoaProfileTest::SetUp();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 EXPECT_EQ(NSWidth(content_frame), NSWidth(titlebar_frame)); 96 EXPECT_EQ(NSWidth(content_frame), NSWidth(titlebar_frame));
97 EXPECT_EQ(NSHeight([[titlebar superview] bounds]), NSMaxY(titlebar_frame)); 97 EXPECT_EQ(NSHeight([[titlebar superview] bounds]), NSMaxY(titlebar_frame));
98 } 98 }
99 99
100 void ClosePanelAndWait(Panel* panel) { 100 void ClosePanelAndWait(Panel* panel) {
101 EXPECT_TRUE(panel); 101 EXPECT_TRUE(panel);
102 // Closing a panel may involve several async tasks. Need to use 102 // Closing a panel may involve several async tasks. Need to use
103 // message pump and wait for the notification. 103 // message pump and wait for the notification.
104 PanelManager* manager = PanelManager::GetInstance(); 104 PanelManager* manager = PanelManager::GetInstance();
105 int panel_count = manager->num_panels(); 105 int panel_count = manager->num_panels();
106 ui_test_utils::WindowedNotificationObserver signal( 106 content::WindowedNotificationObserver signal(
107 chrome::NOTIFICATION_PANEL_CLOSED, 107 chrome::NOTIFICATION_PANEL_CLOSED,
108 content::Source<Panel>(panel)); 108 content::Source<Panel>(panel));
109 panel->Close(); 109 panel->Close();
110 signal.Wait(); 110 signal.Wait();
111 // Now we have one less panel. 111 // Now we have one less panel.
112 EXPECT_EQ(panel_count - 1, manager->num_panels()); 112 EXPECT_EQ(panel_count - 1, manager->num_panels());
113 } 113 }
114 114
115 NSMenuItem* CreateMenuItem(NSMenu* menu, int command_id) { 115 NSMenuItem* CreateMenuItem(NSMenu* menu, int command_id) {
116 NSMenuItem* item = 116 NSMenuItem* item =
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 PanelBrowserWindowCocoa* native_window = 294 PanelBrowserWindowCocoa* native_window =
295 static_cast<PanelBrowserWindowCocoa*>(panel->native_panel()); 295 static_cast<PanelBrowserWindowCocoa*>(panel->native_panel());
296 296
297 PanelTitlebarViewCocoa* titlebar = [native_window->controller_ titlebarView]; 297 PanelTitlebarViewCocoa* titlebar = [native_window->controller_ titlebarView];
298 EXPECT_TRUE(titlebar); 298 EXPECT_TRUE(titlebar);
299 299
300 PanelManager* manager = PanelManager::GetInstance(); 300 PanelManager* manager = PanelManager::GetInstance();
301 EXPECT_EQ(1, manager->num_panels()); 301 EXPECT_EQ(1, manager->num_panels());
302 // Simulate clicking Close Button and wait until the Panel closes. 302 // Simulate clicking Close Button and wait until the Panel closes.
303 ui_test_utils::WindowedNotificationObserver signal( 303 content::WindowedNotificationObserver signal(
304 chrome::NOTIFICATION_PANEL_CLOSED, 304 chrome::NOTIFICATION_PANEL_CLOSED,
305 content::Source<Panel>(panel)); 305 content::Source<Panel>(panel));
306 [titlebar simulateCloseButtonClick]; 306 [titlebar simulateCloseButtonClick];
307 signal.Wait(); 307 signal.Wait();
308 EXPECT_EQ(0, manager->num_panels()); 308 EXPECT_EQ(0, manager->num_panels());
309 } 309 }
310 310
311 // Verify some menu items being properly enabled/disabled for panels. 311 // Verify some menu items being properly enabled/disabled for panels.
312 TEST_F(PanelBrowserWindowCocoaTest, MenuItems) { 312 TEST_F(PanelBrowserWindowCocoaTest, MenuItems) {
313 Panel* panel = CreateTestPanel("Test Panel"); 313 Panel* panel = CreateTestPanel("Test Panel");
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 NSWindow* frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; 411 NSWindow* frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0];
412 EXPECT_NSEQ(frontmostWindow, [native_window->controller_ window]); 412 EXPECT_NSEQ(frontmostWindow, [native_window->controller_ window]);
413 413
414 native_window2->ActivatePanel(); 414 native_window2->ActivatePanel();
415 frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; 415 frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0];
416 EXPECT_NSEQ(frontmostWindow, [native_window2->controller_ window]); 416 EXPECT_NSEQ(frontmostWindow, [native_window2->controller_ window]);
417 417
418 ClosePanelAndWait(panel); 418 ClosePanelAndWait(panel);
419 ClosePanelAndWait(panel2); 419 ClosePanelAndWait(panel2);
420 } 420 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/old_panel_browsertest.cc ('k') | chrome/browser/ui/panels/panel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698