Chromium Code Reviews| 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..2120570378872b2a26a2ca3f0b0b5075b32ae57c 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" |
|
Scott Hess - ex-Googler
2014/07/25 23:59:05
This seems unlikely, now that I look at it.
erikchen
2014/07/26 00:12:16
Won't compile without it. FastResizeView is forwar
Scott Hess - ex-Googler
2014/07/26 00:21:27
Weird. So I'm guessing what you mean is that [con
|
| #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,68 @@ 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]); |
| + |
| + // The height of the contentView varies between full height of the window |
| + // (OSX 10.10+) and full height minus 22 points. Don't make any checks |
| + // against NSMaxY of contentView. |
|
Scott Hess - ex-Googler
2014/07/25 23:59:05
I don't think this comment helps, since this code
erikchen
2014/07/26 00:12:16
Removed the comment.
|
| 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)); |
| + |
| + // Toolbar should start immediately under the tabstrip, but the tabstrip is |
| + // not necessarily fixed with respect to the content view. |
| + EXPECT_EQ(NSMaxY(toolbar), NSMinY(tabstrip)); |
| // Bookmark bar frame is random memory when hidden. |
| if ([controller bookmarkBarVisible]) { |
| @@ -266,10 +316,6 @@ void CheckViewPositions(BrowserWindowController* controller) { |
| EXPECT_EQ(NSMaxY(infobar), NSMinY(toolbar)); |
| EXPECT_TRUE([[controller bookmarkView] isHidden]); |
| } |
| - |
| - // Toolbar should start immediately under the tabstrip, but the tabstrip is |
| - // not necessarily fixed with respect to the content view. |
| - EXPECT_EQ(NSMinY(tabstrip), NSMaxY(toolbar)); |
| } |
| } // end namespace |