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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm

Issue 646703002: mac: Use a full-size content view (reland 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from andre. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
index c8c0e22e09bb0136af95bf6d17a17d190c4060db..d9fec2f54a95995d89c20cc14521c26191c2e2bb 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
@@ -223,25 +223,97 @@ class BrowserWindowControllerTest : public InProcessBrowserTest {
return icon_bottom.y - info_bar_top.y;
}
- // The traffic lights should always be in front of the content view and the
- // tab strip view. Since the traffic lights change across OSX versions, this
- // test verifies that the contentView is in the back, and if the tab strip
- // view is a sibling, it is directly in front of the content view.
- void VerifyTrafficLightZOrder() const {
- NSView* contentView = [[controller() window] contentView];
- NSView* rootView = [contentView superview];
- NSArray* subviews = [rootView subviews];
-
- EXPECT_EQ([controller() tabStripBackgroundView],
- [subviews objectAtIndex:0]);
- EXPECT_EQ(contentView, [subviews objectAtIndex:1]);
-
- NSView* tabStripView = [controller() tabStripView];
- if ([subviews containsObject:tabStripView])
- EXPECT_EQ(tabStripView, [subviews objectAtIndex:2]);
+ // Checks that |view| does not draw on top of |exposedView_|.
+ void CheckViewDoesNotObscure(NSView* view) {
+ NSRect viewWindowFrame = [view convertRect:[view bounds] toView:nil];
+ NSRect viewBeingVerifiedWindowFrame =
+ [exposedView_ convertRect:[exposedView_ bounds] toView:nil];
+
+ // The views do not intersect.
+ if (!NSIntersectsRect(viewBeingVerifiedWindowFrame, viewWindowFrame))
+ return;
+
+ // No view can be above the view being checked.
+ EXPECT_TRUE(belowExposedView_);
+
+ // If |view| is a parent of |exposedView_|, then there's nothing else
+ // to check.
+ NSView* parent = exposedView_;
+ while (parent != nil) {
+ parent = [parent superview];
+ if (parent == view)
+ return;
+ }
+
+ if ([exposedView_ layer])
+ return;
+
+ // If the view being verified doesn't have a layer, then no views that
+ // intersect it can have a layer. The exceptions are the contentView,
+ // chromeContentView and tabStripView, which are layer backed but
+ // transparent.
+ NSArray* exceptions = @[
+ [[view window] contentView],
+ controller().chromeContentView,
+ controller().tabStripView
+ ];
+ if ([exceptions containsObject:view]) {
+ EXPECT_FALSE([view isOpaque]);
+ return;
+ }
+
+ EXPECT_TRUE(![view layer]) << [[view description] UTF8String] << " " <<
+ [NSStringFromRect(viewWindowFrame) UTF8String];
+ }
+
+ // Recursively checks that |view| and its subviews do not draw on top of
+ // |exposedView_|. The recursion passes through all views in order of
+ // back-most in Z-order to front-most in Z-order.
+ void CheckViewsDoNotObscure(NSView* view) {
+ // If this is the view being checked, don't recurse into its subviews. All
+ // future views encountered in the recursion are in front of the view being
+ // checked.
+ if (view == exposedView_) {
+ belowExposedView_ = NO;
+ return;
+ }
+
+ CheckViewDoesNotObscure(view);
+
+ // Perform the recursion.
+ for (NSView* subview in [view subviews])
+ CheckViewsDoNotObscure(subview);
+ }
+
+ // Checks that no views draw in front of |view|.
+ void CheckViewOnTop(NSView* view) {
+ belowExposedView_ = YES;
+ exposedView_ = view;
+ CheckViewsDoNotObscure([[[view window] contentView] superview]);
Andre 2014/10/10 04:37:13 I still think it is not ideal to use instance vari
erikchen 2014/10/10 17:38:08 I moved all of the logic into a new class.
+ }
+
+ // Nothing should draw on top of the window controls.
+ void VerifyWindowControlsZOrder() {
+ NSWindow* window = [controller() window];
+ CheckViewOnTop([window standardWindowButton:NSWindowCloseButton]);
+ CheckViewOnTop([window standardWindowButton:NSWindowMiniaturizeButton]);
+ CheckViewOnTop([window standardWindowButton:NSWindowZoomButton]);
+
+ // There is no fullscreen button on OSX 10.6 or OSX 10.10+.
+ NSView* view = [window standardWindowButton:NSWindowFullScreenButton];
+ if (view)
+ CheckViewOnTop(view);
}
private:
+ // The method CheckViewOnTop() recurses through the views in the view
+ // hierarchy and checks that none of the views obscure |exposedView_|.
+ NSView* exposedView_;
+ // While this flag is true, the views being recursed through are below
+ // |exposedView_| in Z-order. After the recursion passes |exposedView_|, this
+ // flag is set to false.
+ BOOL belowExposedView_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserWindowControllerTest);
};
@@ -500,15 +572,17 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, TrafficLightZOrder) {
// Verify z order immediately after creation.
- VerifyTrafficLightZOrder();
+ VerifyWindowControlsZOrder();
- // Toggle overlay, then verify z order.
+ // Verify z order in and out of overlay.
[controller() showOverlay];
+ VerifyWindowControlsZOrder();
[controller() removeOverlay];
- VerifyTrafficLightZOrder();
+ VerifyWindowControlsZOrder();
- // Toggle immersive fullscreen, then verify z order.
+ // Toggle immersive fullscreen, then verify z order. In immersive fullscreen,
+ // there are no window controls.
[controller() enterImmersiveFullscreen];
[controller() exitImmersiveFullscreen];
- VerifyTrafficLightZOrder();
+ VerifyWindowControlsZOrder();
}
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698