OLD | NEW |
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 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_controll
er.h" | 5 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_controll
er.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_co
ntroller.h" | 8 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_co
ntroller.h" |
9 #include "chrome/browser/ui/cocoa/run_loop_testing.h" | 9 #include "chrome/browser/ui/cocoa/run_loop_testing.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
13 | 12 |
14 typedef InProcessBrowserTest ConstrainedWindowControllerTest; | 13 typedef InProcessBrowserTest ConstrainedWindowControllerTest; |
15 | 14 |
16 IN_PROC_BROWSER_TEST_F(ConstrainedWindowControllerTest, BasicTest) { | 15 IN_PROC_BROWSER_TEST_F(ConstrainedWindowControllerTest, BasicTest) { |
17 TabContents* tab = browser()->tab_strip_model()->GetTabContentsAt(0); | 16 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
18 NSRect frame = NSMakeRect(0, 0, 100, 50); | 17 NSRect frame = NSMakeRect(0, 0, 100, 50); |
19 scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:frame]); | 18 scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:frame]); |
20 scoped_nsobject<ConstrainedWindowController> window_controller( | 19 scoped_nsobject<ConstrainedWindowController> window_controller( |
21 [[ConstrainedWindowController alloc] | 20 [[ConstrainedWindowController alloc] |
22 initWithParentWebContents:tab->web_contents() | 21 initWithParentWebContents:tab |
23 embeddedView:view]); | 22 embeddedView:view]); |
24 | 23 |
25 // The window should match the view size. | 24 // The window should match the view size. |
26 NSWindow* window = [window_controller window]; | 25 NSWindow* window = [window_controller window]; |
27 ConstrainedWindowSheetController* sheetController = | 26 ConstrainedWindowSheetController* sheetController = |
28 [ConstrainedWindowSheetController controllerForSheet:window]; | 27 [ConstrainedWindowSheetController controllerForSheet:window]; |
29 EXPECT_TRUE(sheetController); | 28 EXPECT_TRUE(sheetController); |
30 EXPECT_TRUE(NSEqualSizes(frame.size, [window frame].size)); | 29 EXPECT_TRUE(NSEqualSizes(frame.size, [window frame].size)); |
31 | 30 |
32 // Test that resizing the view resizes the window. | 31 // Test that resizing the view resizes the window. |
33 NSRect new_frame = NSMakeRect(0, 0, 200, 100); | 32 NSRect new_frame = NSMakeRect(0, 0, 200, 100); |
34 [view setFrame:new_frame]; | 33 [view setFrame:new_frame]; |
35 EXPECT_TRUE(NSEqualSizes(new_frame.size, [window frame].size)); | 34 EXPECT_TRUE(NSEqualSizes(new_frame.size, [window frame].size)); |
36 | 35 |
37 // Test that closing the window closes the constrained window. | 36 // Test that closing the window closes the constrained window. |
38 [window_controller close]; | 37 [window_controller close]; |
39 [sheetController endAnimationForSheet:window]; | 38 [sheetController endAnimationForSheet:window]; |
40 chrome::testing::NSRunLoopRunAllPending(); | 39 chrome::testing::NSRunLoopRunAllPending(); |
41 EXPECT_FALSE([ConstrainedWindowSheetController controllerForSheet:window]); | 40 EXPECT_FALSE([ConstrainedWindowSheetController controllerForSheet:window]); |
42 } | 41 } |
OLD | NEW |