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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // Expand the toolbar to 64px and recheck | 485 // Expand the toolbar to 64px and recheck |
486 [controller_ resizeView:toolbar newHeight:64]; | 486 [controller_ resizeView:toolbar newHeight:64]; |
487 CheckViewPositions(controller_); | 487 CheckViewPositions(controller_); |
488 | 488 |
489 // Add a 30px download shelf and recheck | 489 // Add a 30px download shelf and recheck |
490 [controller_ resizeView:download newHeight:30]; | 490 [controller_ resizeView:download newHeight:30]; |
491 CheckViewPositions(controller_); | 491 CheckViewPositions(controller_); |
492 | 492 |
493 // Remove the bookmark bar and recheck | 493 // Remove the bookmark bar and recheck |
494 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, false); | 494 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, false); |
| 495 [controller_ browserWindow]->BookmarkBarStateChanged( |
| 496 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
495 [controller_ resizeView:bookmark newHeight:0]; | 497 [controller_ resizeView:bookmark newHeight:0]; |
496 CheckViewPositions(controller_); | 498 CheckViewPositions(controller_); |
497 | 499 |
498 // Shrink the infobar to 0px and toolbar to 39px and recheck | 500 // Shrink the infobar to 0px and toolbar to 39px and recheck |
499 [controller_ resizeView:infobar newHeight:0]; | 501 [controller_ resizeView:infobar newHeight:0]; |
500 [controller_ resizeView:toolbar newHeight:39]; | 502 [controller_ resizeView:toolbar newHeight:39]; |
501 CheckViewPositions(controller_); | 503 CheckViewPositions(controller_); |
502 } | 504 } |
503 | 505 |
504 // Make sure, by default, the bookmark bar and the toolbar are the same width. | 506 // Make sure, by default, the bookmark bar and the toolbar are the same width. |
505 TEST_F(BrowserWindowControllerTest, BookmarkBarIsSameWidth) { | 507 TEST_F(BrowserWindowControllerTest, BookmarkBarIsSameWidth) { |
506 // Set the pref to the bookmark bar is visible when the toolbar is | 508 // Set the pref to the bookmark bar is visible when the toolbar is |
507 // first created. | 509 // first created. |
508 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true); | 510 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true); |
509 | 511 |
510 // Make sure the bookmark bar is the same width as the toolbar | 512 // Make sure the bookmark bar is the same width as the toolbar |
511 NSView* bookmarkBarView = [controller_ bookmarkView]; | 513 NSView* bookmarkBarView = [controller_ bookmarkView]; |
512 NSView* toolbarView = [controller_ toolbarView]; | 514 NSView* toolbarView = [controller_ toolbarView]; |
513 EXPECT_EQ([toolbarView frame].size.width, | 515 EXPECT_EQ([toolbarView frame].size.width, |
514 [bookmarkBarView frame].size.width); | 516 [bookmarkBarView frame].size.width); |
515 } | 517 } |
516 | 518 |
517 TEST_F(BrowserWindowControllerTest, TestTopRightForBubble) { | 519 TEST_F(BrowserWindowControllerTest, TestTopRightForBubble) { |
518 // The bookmark bubble must be attached to a lit and visible star. | 520 // The bookmark bubble must be attached to a lit and visible star. |
519 [controller_ setStarredState:YES]; | 521 [controller_ setStarredState:YES]; |
520 NSPoint p = [controller_ bookmarkBubblePoint]; | 522 NSPoint p = [controller_ bookmarkBubblePoint]; // Window coordinates. |
521 NSRect all = [[controller_ window] frame]; | 523 NSRect all = [[controller_ window] frame]; // Screen coordinates. |
522 | 524 |
523 // As a sanity check make sure the point is vaguely in the top right | 525 // As a sanity check make sure the point is vaguely in the top right |
524 // of the window. | 526 // of the window. |
525 EXPECT_GT(p.y, all.origin.y + (all.size.height/2)); | 527 EXPECT_GT(p.y, all.size.height / 2); |
526 EXPECT_GT(p.x, all.origin.x + (all.size.width/2)); | 528 EXPECT_GT(p.x, all.size.width / 2); |
527 } | 529 } |
528 | 530 |
529 // By the "zoom frame", we mean what Apple calls the "standard frame". | 531 // By the "zoom frame", we mean what Apple calls the "standard frame". |
530 TEST_F(BrowserWindowControllerTest, TestZoomFrame) { | 532 TEST_F(BrowserWindowControllerTest, TestZoomFrame) { |
531 NSWindow* window = [controller_ window]; | 533 NSWindow* window = [controller_ window]; |
532 ASSERT_TRUE(window); | 534 ASSERT_TRUE(window); |
533 NSRect screenFrame = [[window screen] visibleFrame]; | 535 NSRect screenFrame = [[window screen] visibleFrame]; |
534 ASSERT_FALSE(NSIsEmptyRect(screenFrame)); | 536 ASSERT_FALSE(NSIsEmptyRect(screenFrame)); |
535 | 537 |
536 // Minimum zoomed width is the larger of 60% of available horizontal space or | 538 // Minimum zoomed width is the larger of 60% of available horizontal space or |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 testFullscreenWindow_.reset( | 883 testFullscreenWindow_.reset( |
882 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) | 884 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) |
883 styleMask:NSBorderlessWindowMask | 885 styleMask:NSBorderlessWindowMask |
884 backing:NSBackingStoreBuffered | 886 backing:NSBackingStoreBuffered |
885 defer:NO]); | 887 defer:NO]); |
886 return testFullscreenWindow_.get(); | 888 return testFullscreenWindow_.get(); |
887 } | 889 } |
888 @end | 890 @end |
889 | 891 |
890 /* TODO(???): test other methods of BrowserWindowController */ | 892 /* TODO(???): test other methods of BrowserWindowController */ |
OLD | NEW |