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..28758ef9910aff6bf461f75368970056548e7a43 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,62 @@ 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) { |
|
Scott Hess - ex-Googler
2014/07/25 22:26:53
What, not implementing this as a private category?
|
| + // 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 contentArea = FrameInWindowForView([controller tabContentArea]); |
| + NSRect download = FrameInWindowForView([[controller downloadShelf] view]); |
| EXPECT_EQ(NSMinY(contentView), NSMinY(download)); |
|
Scott Hess - ex-Googler
2014/07/25 22:26:53
Nobody ever checks:
EXPECT_EQ(NSMaxY(contentView
erikchen
2014/07/25 23:22:06
I added a comment. The height of the contentView v
|
| EXPECT_EQ(NSMaxY(download), NSMinY(contentArea)); |
| EXPECT_EQ(NSMaxY(contentArea), NSMinY(infobar)); |
| + EXPECT_EQ(NSMaxY(toolbar), NSMinY(tabstrip)); |
|
Scott Hess - ex-Googler
2014/07/25 22:26:53
Isn't this identical to the last line of the test?
erikchen
2014/07/25 23:22:06
yeah. I removed the last line, and moved the comme
Scott Hess - ex-Googler
2014/07/25 23:59:04
Hmm, I was more wondering why this was added here,
erikchen
2014/07/26 00:12:16
Moved it back down.
|
| // Bookmark bar frame is random memory when hidden. |
| if ([controller bookmarkBarVisible]) { |