| Index: chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
|
| diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
|
| index 0af185155d892fd26827375f066e4c1a507eb179..44b1fa95654ae7136c5ebda1095798a8c2c51fdc 100644
|
| --- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
|
| +++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
|
| @@ -20,6 +20,7 @@
|
| #include "chrome/browser/ui/browser_list.h"
|
| #include "chrome/browser/ui/browser_window.h"
|
| #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
|
| +#import "chrome/browser/ui/cocoa/fast_resize_view.h"
|
| #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
|
| #import "chrome/browser/ui/cocoa/nsview_additions.h"
|
| #include "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
|
| @@ -242,19 +243,61 @@ TEST_F(BrowserWindowControllerTest, TestIncognitoWidthSpace) {
|
|
|
| namespace {
|
|
|
| +// Returns the frame of the view in window coordinates.
|
| +NSRect FrameInWindowForView(NSView* view) {
|
| + return [[view superview] convertRect:[view frame] toView:nil];
|
| +}
|
| +
|
| +// Whether the view's frame is within the bounds of the superview.
|
| +BOOL ViewContainmentValid(NSView* view) {
|
| + if (NSIsEmptyRect([view frame]))
|
| + return true;
|
| +
|
| + return NSContainsRect([[view superview] bounds], [view frame]);
|
| +}
|
| +
|
| +// Checks the view hierarchy rooted at |view| to ensure that each view is
|
| +// properly contained.
|
| +BOOL ViewHierarchyContainmentValid(NSView* view) {
|
| + // TODO(erikchen): Fix these views to have correct containment.
|
| + // http://crbug.com/397665.
|
| + if ([view isKindOfClass:NSClassFromString(@"DownloadShelfView")])
|
| + return YES;
|
| + if ([view isKindOfClass:NSClassFromString(@"BookmarkBarToolbarView")])
|
| + return YES;
|
| + if ([view isKindOfClass:NSClassFromString(@"BrowserActionsContainerView")])
|
| + return YES;
|
| +
|
| + if (!ViewContainmentValid(view)) {
|
| + LOG(ERROR) << "View violates containment: " <<
|
| + [[view description] UTF8String];
|
| + return false;
|
| + }
|
| +
|
| + for (NSView* subview in [view subviews]) {
|
| + BOOL result = ViewHierarchyContainmentValid(subview);
|
| + if (!result)
|
| + return false;
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| // Verifies that the toolbar, infobar, tab content area, and download shelf
|
| // completely fill the area under the tabstrip.
|
| void CheckViewPositions(BrowserWindowController* controller) {
|
| - NSRect contentView = [[[controller window] contentView] bounds];
|
| - NSRect tabstrip = [[controller tabStripView] frame];
|
| - NSRect toolbar = [[controller toolbarView] frame];
|
| - NSRect infobar = [[controller infoBarContainerView] frame];
|
| - NSRect contentArea = [[controller tabContentArea] frame];
|
| - NSRect download = [[[controller downloadShelf] view] frame];
|
| + EXPECT_TRUE(ViewHierarchyContainmentValid([[controller window] contentView]));
|
| +
|
| + NSRect contentView = FrameInWindowForView([[controller window] contentView]);
|
| + NSRect tabstrip = FrameInWindowForView([controller tabStripView]);
|
| + NSRect toolbar = FrameInWindowForView([controller toolbarView]);
|
| + NSRect infobar = FrameInWindowForView([controller infoBarContainerView]);
|
| + NSRect tabContent = FrameInWindowForView([controller tabContentArea]);
|
| + NSRect download = FrameInWindowForView([[controller downloadShelf] view]);
|
|
|
| EXPECT_EQ(NSMinY(contentView), NSMinY(download));
|
| - EXPECT_EQ(NSMaxY(download), NSMinY(contentArea));
|
| - EXPECT_EQ(NSMaxY(contentArea), NSMinY(infobar));
|
| + EXPECT_EQ(NSMaxY(download), NSMinY(tabContent));
|
| + EXPECT_EQ(NSMaxY(tabContent), NSMinY(infobar));
|
|
|
| // Bookmark bar frame is random memory when hidden.
|
| if ([controller bookmarkBarVisible]) {
|
|
|