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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_unittest.mm

Issue 490123003: Move bookmark_pref_names.* into bookmarks namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE Created 6 years, 3 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 (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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 TEST_F(BrowserWindowControllerTest, TestFullScreenWindow) { 118 TEST_F(BrowserWindowControllerTest, TestFullScreenWindow) {
119 // Confirm that |-createFullscreenWindow| doesn't return nil. 119 // Confirm that |-createFullscreenWindow| doesn't return nil.
120 // See BrowserWindowFullScreenControllerTest for more fullscreen tests. 120 // See BrowserWindowFullScreenControllerTest for more fullscreen tests.
121 EXPECT_TRUE([controller_ createFullscreenWindow]); 121 EXPECT_TRUE([controller_ createFullscreenWindow]);
122 } 122 }
123 123
124 TEST_F(BrowserWindowControllerTest, TestNormal) { 124 TEST_F(BrowserWindowControllerTest, TestNormal) {
125 // Force the bookmark bar to be shown. 125 // Force the bookmark bar to be shown.
126 profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); 126 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true);
127 [controller_ browserWindow]->BookmarkBarStateChanged( 127 [controller_ browserWindow]->BookmarkBarStateChanged(
128 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 128 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
129 129
130 // Make sure a normal BrowserWindowController is, uh, normal. 130 // Make sure a normal BrowserWindowController is, uh, normal.
131 EXPECT_TRUE([controller_ isTabbedWindow]); 131 EXPECT_TRUE([controller_ isTabbedWindow]);
132 EXPECT_TRUE([controller_ hasTabStrip]); 132 EXPECT_TRUE([controller_ hasTabStrip]);
133 EXPECT_FALSE([controller_ hasTitleBar]); 133 EXPECT_FALSE([controller_ hasTitleBar]);
134 EXPECT_TRUE([controller_ isBookmarkBarVisible]); 134 EXPECT_TRUE([controller_ isBookmarkBarVisible]);
135 135
136 // And make sure a controller for a pop-up window is not normal. 136 // And make sure a controller for a pop-up window is not normal.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 TEST_F(BrowserWindowControllerTest, TestTheme) { 204 TEST_F(BrowserWindowControllerTest, TestTheme) {
205 [controller_ userChangedTheme]; 205 [controller_ userChangedTheme];
206 } 206 }
207 207
208 TEST_F(BrowserWindowControllerTest, BookmarkBarControllerIndirection) { 208 TEST_F(BrowserWindowControllerTest, BookmarkBarControllerIndirection) {
209 EXPECT_FALSE([controller_ isBookmarkBarVisible]); 209 EXPECT_FALSE([controller_ isBookmarkBarVisible]);
210 210
211 // Explicitly show the bar. Can't use chrome::ToggleBookmarkBarWhenVisible() 211 // Explicitly show the bar. Can't use chrome::ToggleBookmarkBarWhenVisible()
212 // because of the notification issues. 212 // because of the notification issues.
213 profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); 213 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true);
214 214
215 [controller_ browserWindow]->BookmarkBarStateChanged( 215 [controller_ browserWindow]->BookmarkBarStateChanged(
216 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 216 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
217 EXPECT_TRUE([controller_ isBookmarkBarVisible]); 217 EXPECT_TRUE([controller_ isBookmarkBarVisible]);
218 } 218 }
219 219
220 #if 0 220 #if 0
221 // TODO(jrg): This crashes trying to create the BookmarkBarController, adding 221 // TODO(jrg): This crashes trying to create the BookmarkBarController, adding
222 // an observer to the BookmarkModel. 222 // an observer to the BookmarkModel.
223 TEST_F(BrowserWindowControllerTest, TestIncognitoWidthSpace) { 223 TEST_F(BrowserWindowControllerTest, TestIncognitoWidthSpace) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 CheckViewPositions(controller_); 438 CheckViewPositions(controller_);
439 439
440 // Shrink the infobar to 0px and toolbar to 39px and recheck 440 // Shrink the infobar to 0px and toolbar to 39px and recheck
441 [controller_ resizeView:infobar newHeight:0]; 441 [controller_ resizeView:infobar newHeight:0];
442 [controller_ resizeView:toolbar newHeight:39]; 442 [controller_ resizeView:toolbar newHeight:39];
443 CheckViewPositions(controller_); 443 CheckViewPositions(controller_);
444 } 444 }
445 445
446 TEST_F(BrowserWindowControllerTest, TestResizeViewsWithBookmarkBar) { 446 TEST_F(BrowserWindowControllerTest, TestResizeViewsWithBookmarkBar) {
447 // Force a display of the bookmark bar. 447 // Force a display of the bookmark bar.
448 profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); 448 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true);
449 [controller_ browserWindow]->BookmarkBarStateChanged( 449 [controller_ browserWindow]->BookmarkBarStateChanged(
450 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 450 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
451 451
452 TabStripView* tabstrip = [controller_ tabStripView]; 452 TabStripView* tabstrip = [controller_ tabStripView];
453 NSView* contentView = [[tabstrip window] contentView]; 453 NSView* contentView = [[tabstrip window] contentView];
454 NSView* toolbar = [controller_ toolbarView]; 454 NSView* toolbar = [controller_ toolbarView];
455 NSView* bookmark = [controller_ bookmarkView]; 455 NSView* bookmark = [controller_ bookmarkView];
456 NSView* infobar = [controller_ infoBarContainerView]; 456 NSView* infobar = [controller_ infoBarContainerView];
457 457
458 // We need to muck with the views a bit to put us in a consistent state before 458 // We need to muck with the views a bit to put us in a consistent state before
(...skipping 25 matching lines...) Expand all
484 484
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(prefs::kShowBookmarkBar, false); 494 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, false);
495 [controller_ resizeView:bookmark newHeight:0]; 495 [controller_ resizeView:bookmark newHeight:0];
496 CheckViewPositions(controller_); 496 CheckViewPositions(controller_);
497 497
498 // Shrink the infobar to 0px and toolbar to 39px and recheck 498 // Shrink the infobar to 0px and toolbar to 39px and recheck
499 [controller_ resizeView:infobar newHeight:0]; 499 [controller_ resizeView:infobar newHeight:0];
500 [controller_ resizeView:toolbar newHeight:39]; 500 [controller_ resizeView:toolbar newHeight:39];
501 CheckViewPositions(controller_); 501 CheckViewPositions(controller_);
502 } 502 }
503 503
504 // Make sure, by default, the bookmark bar and the toolbar are the same width. 504 // Make sure, by default, the bookmark bar and the toolbar are the same width.
505 TEST_F(BrowserWindowControllerTest, BookmarkBarIsSameWidth) { 505 TEST_F(BrowserWindowControllerTest, BookmarkBarIsSameWidth) {
506 // Set the pref to the bookmark bar is visible when the toolbar is 506 // Set the pref to the bookmark bar is visible when the toolbar is
507 // first created. 507 // first created.
508 profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); 508 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true);
509 509
510 // Make sure the bookmark bar is the same width as the toolbar 510 // Make sure the bookmark bar is the same width as the toolbar
511 NSView* bookmarkBarView = [controller_ bookmarkView]; 511 NSView* bookmarkBarView = [controller_ bookmarkView];
512 NSView* toolbarView = [controller_ toolbarView]; 512 NSView* toolbarView = [controller_ toolbarView];
513 EXPECT_EQ([toolbarView frame].size.width, 513 EXPECT_EQ([toolbarView frame].size.width,
514 [bookmarkBarView frame].size.width); 514 [bookmarkBarView frame].size.width);
515 } 515 }
516 516
517 TEST_F(BrowserWindowControllerTest, TestTopRightForBubble) { 517 TEST_F(BrowserWindowControllerTest, TestTopRightForBubble) {
518 // The bookmark bubble must be attached to a lit and visible star. 518 // The bookmark bubble must be attached to a lit and visible star.
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 currentProfile:profile()]; 766 currentProfile:profile()];
767 767
768 EXPECT_TRUE([followingNonSeparator isEnabled]); 768 EXPECT_TRUE([followingNonSeparator isEnabled]);
769 EXPECT_FALSE([signinMenuItem isHidden]); 769 EXPECT_FALSE([signinMenuItem isHidden]);
770 EXPECT_TRUE([followingNonSeparator isHidden]); 770 EXPECT_TRUE([followingNonSeparator isHidden]);
771 } 771 }
772 772
773 // Verify that hit testing works correctly when the bookmark bar overlaps 773 // Verify that hit testing works correctly when the bookmark bar overlaps
774 // web contents. 774 // web contents.
775 TEST_F(BrowserWindowControllerTest, BookmarkBarHitTest) { 775 TEST_F(BrowserWindowControllerTest, BookmarkBarHitTest) {
776 profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); 776 profile()->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true);
777 [controller_ browserWindow]->BookmarkBarStateChanged( 777 [controller_ browserWindow]->BookmarkBarStateChanged(
778 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 778 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
779 779
780 NSView* bookmarkView = [controller_ bookmarkView]; 780 NSView* bookmarkView = [controller_ bookmarkView];
781 NSView* contentView = [[controller_ window] contentView]; 781 NSView* contentView = [[controller_ window] contentView];
782 NSPoint point = [bookmarkView convertPoint:NSMakePoint(1, 1) 782 NSPoint point = [bookmarkView convertPoint:NSMakePoint(1, 1)
783 toView:[contentView superview]]; 783 toView:[contentView superview]];
784 784
785 EXPECT_TRUE([[contentView hitTest:point] isDescendantOf:bookmarkView]); 785 EXPECT_TRUE([[contentView hitTest:point] isDescendantOf:bookmarkView]);
786 } 786 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 testFullscreenWindow_.reset( 881 testFullscreenWindow_.reset(
882 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) 882 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400)
883 styleMask:NSBorderlessWindowMask 883 styleMask:NSBorderlessWindowMask
884 backing:NSBackingStoreBuffered 884 backing:NSBackingStoreBuffered
885 defer:NO]); 885 defer:NO]);
886 return testFullscreenWindow_.get(); 886 return testFullscreenWindow_.get();
887 } 887 }
888 @end 888 @end
889 889
890 /* TODO(???): test other methods of BrowserWindowController */ 890 /* TODO(???): test other methods of BrowserWindowController */
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_cocoa.mm ('k') | chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698