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

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

Issue 573143002: Mac: Give bubble windows an initial position before showing them. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/base_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/base_bubble_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 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
10 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 10 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 NSRect frame = [[controller_ window] frame]; 191 NSRect frame = [[controller_ window] frame];
192 // Make sure the bubble size hasn't changed. 192 // Make sure the bubble size hasn't changed.
193 EXPECT_EQ(frame.size.width, kBubbleWindowWidth); 193 EXPECT_EQ(frame.size.width, kBubbleWindowWidth);
194 EXPECT_EQ(frame.size.height, kBubbleWindowHeight); 194 EXPECT_EQ(frame.size.height, kBubbleWindowHeight);
195 // Make sure the bubble arrow points to the anchor. 195 // Make sure the bubble arrow points to the anchor.
196 EXPECT_EQ(NSMidX(frame), kAnchorPointX); 196 EXPECT_EQ(NSMidX(frame), kAnchorPointX);
197 EXPECT_GE(NSMaxY(frame), kAnchorPointY); 197 EXPECT_GE(NSMaxY(frame), kAnchorPointY);
198 } 198 }
199 199
200 // Test that the window is given an initial position before being shown. This
201 // ensures offscreen initialization is done using correct screen metrics.
202 TEST_F(BaseBubbleControllerTest, PositionedBeforeShow) {
203 // Verify default alignment settings, used when initialized in SetUp().
204 EXPECT_EQ(info_bubble::kTopRight, [[controller_ bubble] arrowLocation]);
205 EXPECT_EQ(info_bubble::kAlignArrowToAnchor, [[controller_ bubble] alignment]);
206
207 // Verify the default frame (positioned relative to the test_window() origin).
208 NSRect frame = [[controller_ window] frame];
209 EXPECT_EQ(NSMaxX(frame) - info_bubble::kBubbleArrowXOffset -
210 floorf(info_bubble::kBubbleArrowWidth / 2.0), kAnchorPointX);
211 EXPECT_EQ(NSMaxY(frame), kAnchorPointY);
212 }
213
200 // Tests that when a new window gets key state (and the bubble resigns) that 214 // Tests that when a new window gets key state (and the bubble resigns) that
201 // the key window changes. 215 // the key window changes.
202 TEST_F(BaseBubbleControllerTest, ResignKeyCloses) { 216 TEST_F(BaseBubbleControllerTest, ResignKeyCloses) {
203 // Closing the bubble will autorelease the controller. 217 // Closing the bubble will autorelease the controller.
204 base::scoped_nsobject<BaseBubbleController> keep_alive([controller_ retain]); 218 base::scoped_nsobject<BaseBubbleController> keep_alive([controller_ retain]);
205 219
206 NSWindow* bubble_window = [controller_ window]; 220 NSWindow* bubble_window = [controller_ window];
207 EXPECT_FALSE([bubble_window isVisible]); 221 EXPECT_FALSE([bubble_window isVisible]);
208 222
209 base::scoped_nsobject<NSWindow> other_window( 223 base::scoped_nsobject<NSWindow> other_window(
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 [NSApp sendEvent:event]; 348 [NSApp sendEvent:event];
335 349
336 // When we got here, menu has already run its RunLoop. 350 // When we got here, menu has already run its RunLoop.
337 // See -[ContextualMenuController menuWillOpen:]. 351 // See -[ContextualMenuController menuWillOpen:].
338 EXPECT_FALSE([window isVisible]); 352 EXPECT_FALSE([window isVisible]);
339 353
340 EXPECT_FALSE([menu_controller isMenuOpen]); 354 EXPECT_FALSE([menu_controller isMenuOpen]);
341 EXPECT_TRUE([menu_controller didOpen]); 355 EXPECT_TRUE([menu_controller didOpen]);
342 } 356 }
343 357
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698