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

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

Issue 75543008: Fix alignment for bubbles with center-arrows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Kill blank line. Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/base_bubble_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 NSRect frame = [[controller_ window] frame]; 107 NSRect frame = [[controller_ window] frame];
108 // Make sure the bubble size hasn't changed. 108 // Make sure the bubble size hasn't changed.
109 EXPECT_EQ(frame.size.width, kBubbleWindowWidth); 109 EXPECT_EQ(frame.size.width, kBubbleWindowWidth);
110 EXPECT_EQ(frame.size.height, kBubbleWindowHeight); 110 EXPECT_EQ(frame.size.height, kBubbleWindowHeight);
111 // Make sure the bubble arrow points to the anchor. 111 // Make sure the bubble arrow points to the anchor.
112 EXPECT_EQ(NSMaxX(frame) - info_bubble::kBubbleArrowXOffset - 112 EXPECT_EQ(NSMaxX(frame) - info_bubble::kBubbleArrowXOffset -
113 floorf(info_bubble::kBubbleArrowWidth / 2.0), kAnchorPointX); 113 floorf(info_bubble::kBubbleArrowWidth / 2.0), kAnchorPointX);
114 EXPECT_GE(NSMaxY(frame), kAnchorPointY); 114 EXPECT_GE(NSMaxY(frame), kAnchorPointY);
115 } 115 }
116 116
117 // Test that kAlignArrowToAnchor and a center bubble arrow correctly align
118 // the bubble towards the anchor point.
119 TEST_F(BaseBubbleControllerTest, AnchorAlignCenterArrow) {
120 [[controller_ bubble] setArrowLocation:info_bubble::kTopCenter];
121 [[controller_ bubble] setAlignment:info_bubble::kAlignArrowToAnchor];
122 [controller_ showWindow:nil];
123
124 NSRect frame = [[controller_ window] frame];
125 // Make sure the bubble size hasn't changed.
126 EXPECT_EQ(frame.size.width, kBubbleWindowWidth);
127 EXPECT_EQ(frame.size.height, kBubbleWindowHeight);
128 // Make sure the bubble arrow points to the anchor.
129 EXPECT_EQ(NSMidX(frame), kAnchorPointX);
130 EXPECT_GE(NSMaxY(frame), kAnchorPointY);
131 }
132
117 // Tests that when a new window gets key state (and the bubble resigns) that 133 // Tests that when a new window gets key state (and the bubble resigns) that
118 // the key window changes. 134 // the key window changes.
119 TEST_F(BaseBubbleControllerTest, ResignKeyCloses) { 135 TEST_F(BaseBubbleControllerTest, ResignKeyCloses) {
120 // Closing the bubble will autorelease the controller. 136 // Closing the bubble will autorelease the controller.
121 base::scoped_nsobject<BaseBubbleController> keep_alive([controller_ retain]); 137 base::scoped_nsobject<BaseBubbleController> keep_alive([controller_ retain]);
122 138
123 NSWindow* bubble_window = [controller_ window]; 139 NSWindow* bubble_window = [controller_ window];
124 EXPECT_FALSE([bubble_window isVisible]); 140 EXPECT_FALSE([bubble_window isVisible]);
125 141
126 base::scoped_nsobject<NSWindow> other_window( 142 base::scoped_nsobject<NSWindow> other_window(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 EXPECT_TRUE([window isVisible]); 199 EXPECT_TRUE([window isVisible]);
184 200
185 [controller_ setShouldCloseOnResignKey:YES]; 201 [controller_ setShouldCloseOnResignKey:YES];
186 event = cocoa_test_event_utils::LeftMouseDownAtPointInWindow( 202 event = cocoa_test_event_utils::LeftMouseDownAtPointInWindow(
187 NSMakePoint(10, 10), test_window()); 203 NSMakePoint(10, 10), test_window());
188 [NSApp sendEvent:event]; 204 [NSApp sendEvent:event];
189 chrome::testing::NSRunLoopRunAllPending(); 205 chrome::testing::NSRunLoopRunAllPending();
190 206
191 EXPECT_FALSE([window isVisible]); 207 EXPECT_FALSE([window isVisible]);
192 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/base_bubble_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698