OLD | NEW |
---|---|
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 Loading... | |
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 | |
Robert Sesek
2013/11/19 15:54:14
nit: extra blank line
groby-ooo-7-16
2013/11/19 18:59:48
Done.
| |
133 | |
117 // Tests that when a new window gets key state (and the bubble resigns) that | 134 // Tests that when a new window gets key state (and the bubble resigns) that |
118 // the key window changes. | 135 // the key window changes. |
119 TEST_F(BaseBubbleControllerTest, ResignKeyCloses) { | 136 TEST_F(BaseBubbleControllerTest, ResignKeyCloses) { |
120 // Closing the bubble will autorelease the controller. | 137 // Closing the bubble will autorelease the controller. |
121 base::scoped_nsobject<BaseBubbleController> keep_alive([controller_ retain]); | 138 base::scoped_nsobject<BaseBubbleController> keep_alive([controller_ retain]); |
122 | 139 |
123 NSWindow* bubble_window = [controller_ window]; | 140 NSWindow* bubble_window = [controller_ window]; |
124 EXPECT_FALSE([bubble_window isVisible]); | 141 EXPECT_FALSE([bubble_window isVisible]); |
125 | 142 |
126 base::scoped_nsobject<NSWindow> other_window( | 143 base::scoped_nsobject<NSWindow> other_window( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 EXPECT_TRUE([window isVisible]); | 200 EXPECT_TRUE([window isVisible]); |
184 | 201 |
185 [controller_ setShouldCloseOnResignKey:YES]; | 202 [controller_ setShouldCloseOnResignKey:YES]; |
186 event = cocoa_test_event_utils::LeftMouseDownAtPointInWindow( | 203 event = cocoa_test_event_utils::LeftMouseDownAtPointInWindow( |
187 NSMakePoint(10, 10), test_window()); | 204 NSMakePoint(10, 10), test_window()); |
188 [NSApp sendEvent:event]; | 205 [NSApp sendEvent:event]; |
189 chrome::testing::NSRunLoopRunAllPending(); | 206 chrome::testing::NSRunLoopRunAllPending(); |
190 | 207 |
191 EXPECT_FALSE([window isVisible]); | 208 EXPECT_FALSE([window isVisible]); |
192 } | 209 } |
OLD | NEW |