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

Side by Side Diff: ui/views/bubble/bubble_frame_view_unittest.cc

Issue 10905311: Consolidate bubble border code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments in #4 and add tests Created 8 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 | Annotate | Revision Log
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 #include "ui/base/hit_test.h" 5 #include "ui/base/hit_test.h"
6 #include "ui/gfx/insets.h" 6 #include "ui/gfx/insets.h"
7 #include "ui/views/bubble/bubble_border.h" 7 #include "ui/views/bubble/bubble_border.h"
8 #include "ui/views/bubble/bubble_delegate.h" 8 #include "ui/views/bubble/bubble_delegate.h"
9 #include "ui/views/bubble/bubble_frame_view.h" 9 #include "ui/views/bubble/bubble_frame_view.h"
10 #include "ui/views/test/views_test_base.h" 10 #include "ui/views/test/views_test_base.h"
11 #include "ui/views/widget/widget.h" 11 #include "ui/views/widget/widget.h"
12 12
13 namespace views { 13 namespace views {
14 14
15 typedef ViewsTestBase BubbleFrameViewTest; 15 typedef ViewsTestBase BubbleFrameViewTest;
16 16
17 namespace {
18
17 const BubbleBorder::ArrowLocation kArrow = BubbleBorder::TOP_LEFT; 19 const BubbleBorder::ArrowLocation kArrow = BubbleBorder::TOP_LEFT;
18 const int kBubbleWidth = 200; 20 const int kBubbleWidth = 200;
19 const int kBubbleHeight = 200; 21 const int kBubbleHeight = 200;
20 const SkColor kBackgroundColor = SK_ColorRED; 22 const SkColor kBackgroundColor = SK_ColorRED;
21 const int kDefaultMargin = 6; 23 const int kDefaultMargin = 6;
22 24 const int kIgnore = -1;
msw 2012/09/20 00:07:23 nit: remove
xiyuan 2012/09/20 16:56:51 Done.
23 namespace {
24 25
25 class SizedBubbleDelegateView : public BubbleDelegateView { 26 class SizedBubbleDelegateView : public BubbleDelegateView {
26 public: 27 public:
27 SizedBubbleDelegateView(); 28 SizedBubbleDelegateView();
28 virtual ~SizedBubbleDelegateView(); 29 virtual ~SizedBubbleDelegateView();
29 30
30 // View overrides: 31 // View overrides:
31 virtual gfx::Size GetPreferredSize() OVERRIDE; 32 virtual gfx::Size GetPreferredSize() OVERRIDE;
32 33
33 private: 34 private:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 gfx::Insets insets; 109 gfx::Insets insets;
109 frame.bubble_border()->GetInsets(&insets); 110 frame.bubble_border()->GetInsets(&insets);
110 int xposition = 95 - insets.width(); 111 int xposition = 95 - insets.width();
111 112
112 // Test that the info bubble displays normally when it fits. 113 // Test that the info bubble displays normally when it fits.
113 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); 114 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT);
114 window_bounds = frame.GetUpdatedWindowBounds( 115 window_bounds = frame.GetUpdatedWindowBounds(
115 gfx::Rect(100, 100, 50, 50), // |anchor_rect| 116 gfx::Rect(100, 100, 50, 50), // |anchor_rect|
116 gfx::Size(500, 500), // |client_size| 117 gfx::Size(500, 500), // |client_size|
117 true); // |try_mirroring_arrow| 118 true); // |adjust_if_offscreen|
118 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); 119 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location());
119 EXPECT_GT(window_bounds.x(), xposition); 120 EXPECT_GT(window_bounds.x(), xposition);
120 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for 121 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
121 // arrow overlap. 122 // arrow overlap.
122 123
123 // Test bubble not fitting on left. 124 // Test bubble not fitting on left.
124 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); 125 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT);
125 window_bounds = frame.GetUpdatedWindowBounds( 126 window_bounds = frame.GetUpdatedWindowBounds(
126 gfx::Rect(100, 100, 50, 50), // |anchor_rect| 127 gfx::Rect(100, 100, 50, 50), // |anchor_rect|
127 gfx::Size(500, 500), // |client_size| 128 gfx::Size(500, 500), // |client_size|
128 true); // |try_mirroring_arrow| 129 true); // |adjust_if_offscreen|
129 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); 130 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location());
130 EXPECT_GT(window_bounds.x(), xposition); 131 EXPECT_GT(window_bounds.x(), xposition);
131 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for 132 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
132 // arrow overlap. 133 // arrow overlap.
133 134
134 // Test bubble not fitting on left or top. 135 // Test bubble not fitting on left or top.
135 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_RIGHT); 136 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_RIGHT);
136 window_bounds = frame.GetUpdatedWindowBounds( 137 window_bounds = frame.GetUpdatedWindowBounds(
137 gfx::Rect(100, 100, 50, 50), // |anchor_rect| 138 gfx::Rect(100, 100, 50, 50), // |anchor_rect|
138 gfx::Size(500, 500), // |client_size| 139 gfx::Size(500, 500), // |client_size|
139 true); // |try_mirroring_arrow| 140 true); // |adjust_if_offscreen|
140 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); 141 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location());
141 EXPECT_GT(window_bounds.x(), xposition); 142 EXPECT_GT(window_bounds.x(), xposition);
142 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for 143 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
143 // arrow overlap. 144 // arrow overlap.
144 145
145 // Test bubble not fitting on top. 146 // Test bubble not fitting on top.
146 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_LEFT); 147 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_LEFT);
147 window_bounds = frame.GetUpdatedWindowBounds( 148 window_bounds = frame.GetUpdatedWindowBounds(
148 gfx::Rect(100, 100, 50, 50), // |anchor_rect| 149 gfx::Rect(100, 100, 50, 50), // |anchor_rect|
149 gfx::Size(500, 500), // |client_size| 150 gfx::Size(500, 500), // |client_size|
150 true); // |try_mirroring_arrow| 151 true); // |adjust_if_offscreen|
151 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); 152 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location());
152 EXPECT_GT(window_bounds.x(), xposition); 153 EXPECT_GT(window_bounds.x(), xposition);
153 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for 154 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
154 // arrow overlap. 155 // arrow overlap.
155 156
156 // Test bubble not fitting on top and right. 157 // Test bubble not fitting on top and right.
157 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_LEFT); 158 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_LEFT);
158 window_bounds = frame.GetUpdatedWindowBounds( 159 window_bounds = frame.GetUpdatedWindowBounds(
159 gfx::Rect(900, 100, 50, 50), // |anchor_rect| 160 gfx::Rect(900, 100, 50, 50), // |anchor_rect|
160 gfx::Size(500, 500), // |client_size| 161 gfx::Size(500, 500), // |client_size|
161 true); // |try_mirroring_arrow| 162 true); // |adjust_if_offscreen|
162 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); 163 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location());
163 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); 164 EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
164 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for 165 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
165 // arrow overlap. 166 // arrow overlap.
166 167
167 // Test bubble not fitting on right. 168 // Test bubble not fitting on right.
168 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); 169 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT);
169 window_bounds = frame.GetUpdatedWindowBounds( 170 window_bounds = frame.GetUpdatedWindowBounds(
170 gfx::Rect(900, 100, 50, 50), // |anchor_rect| 171 gfx::Rect(900, 100, 50, 50), // |anchor_rect|
171 gfx::Size(500, 500), // |client_size| 172 gfx::Size(500, 500), // |client_size|
172 true); // |try_mirroring_arrow| 173 true); // |adjust_if_offscreen|
173 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); 174 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location());
174 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); 175 EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
175 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for 176 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
176 // arrow overlap. 177 // arrow overlap.
177 178
178 // Test bubble not fitting on bottom and right. 179 // Test bubble not fitting on bottom and right.
179 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); 180 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT);
180 window_bounds = frame.GetUpdatedWindowBounds( 181 window_bounds = frame.GetUpdatedWindowBounds(
181 gfx::Rect(900, 900, 50, 50), // |anchor_rect| 182 gfx::Rect(900, 900, 50, 50), // |anchor_rect|
182 gfx::Size(500, 500), // |client_size| 183 gfx::Size(500, 500), // |client_size|
183 true); // |try_mirroring_arrow| 184 true); // |adjust_if_offscreen|
184 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT, 185 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT,
185 frame.bubble_border()->arrow_location()); 186 frame.bubble_border()->arrow_location());
186 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); 187 EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
187 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate 188 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate
188 // for arrow height. 189 // for arrow height.
189 190
190 // Test bubble not fitting at the bottom. 191 // Test bubble not fitting at the bottom.
191 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); 192 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT);
192 window_bounds = frame.GetUpdatedWindowBounds( 193 window_bounds = frame.GetUpdatedWindowBounds(
193 gfx::Rect(100, 900, 50, 50), // |anchor_rect| 194 gfx::Rect(100, 900, 50, 50), // |anchor_rect|
194 gfx::Size(500, 500), // |client_size| 195 gfx::Size(500, 500), // |client_size|
195 true); // |try_mirroring_arrow| 196 true); // |adjust_if_offscreen|
196 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT, frame.bubble_border()->arrow_location()); 197 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT, frame.bubble_border()->arrow_location());
197 // The window should be right aligned with the anchor_rect. 198 // The window should be right aligned with the anchor_rect.
198 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); 199 EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
199 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate 200 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate
200 // for arrow height. 201 // for arrow height.
201 202
202 // Test bubble not fitting at the bottom and left. 203 // Test bubble not fitting at the bottom and left.
203 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); 204 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT);
204 window_bounds = frame.GetUpdatedWindowBounds( 205 window_bounds = frame.GetUpdatedWindowBounds(
205 gfx::Rect(100, 900, 50, 50), // |anchor_rect| 206 gfx::Rect(100, 900, 50, 50), // |anchor_rect|
206 gfx::Size(500, 500), // |client_size| 207 gfx::Size(500, 500), // |client_size|
207 true); // |try_mirroring_arrow| 208 true); // |adjust_if_offscreen|
208 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT, frame.bubble_border()->arrow_location()); 209 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT, frame.bubble_border()->arrow_location());
209 // The window should be right aligned with the anchor_rect. 210 // The window should be right aligned with the anchor_rect.
210 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); 211 EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
211 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate 212 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate
212 // for arrow height. 213 // for arrow height.
213 } 214 }
214 215
215 // Tests that the arrow is not moved when the info-bubble does not fit the 216 // Tests that the arrow is not moved when the info-bubble does not fit the
216 // screen but moving it would make matter worse. 217 // screen but moving it would make matter worse.
217 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsMirroringFails) { 218 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsMirroringFails) {
218 TestBubbleFrameView frame; 219 TestBubbleFrameView frame;
219 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); 220 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT);
220 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( 221 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds(
221 gfx::Rect(400, 100, 50, 50), // |anchor_rect| 222 gfx::Rect(400, 100, 50, 50), // |anchor_rect|
222 gfx::Size(500, 700), // |client_size| 223 gfx::Size(500, 700), // |client_size|
223 true); // |try_mirroring_arrow| 224 true); // |adjust_if_offscreen|
224 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); 225 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location());
225 } 226 }
226 227
227 // Test that the arrow will not be mirrored when |try_mirroring_arrow| is false. 228 // Test that the arrow will not be mirrored when |adjust_if_offscreen| is false.
228 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsDontTryMirror) { 229 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsDontTryMirror) {
229 TestBubbleFrameView frame; 230 TestBubbleFrameView frame;
230 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); 231 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT);
231 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( 232 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds(
232 gfx::Rect(100, 900, 50, 50), // |anchor_rect| 233 gfx::Rect(100, 900, 50, 50), // |anchor_rect|
233 gfx::Size(500, 500), // |client_size| 234 gfx::Size(500, 500), // |client_size|
234 false); // |try_mirroring_arrow| 235 false); // |adjust_if_offscreen|
235 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); 236 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location());
236 // The coordinates should be pointing to anchor_rect from TOP_RIGHT. 237 // The coordinates should be pointing to anchor_rect from TOP_RIGHT.
237 EXPECT_LT(window_bounds.x(), 100 + 50 - 500); 238 EXPECT_LT(window_bounds.x(), 100 + 50 - 500);
238 EXPECT_GT(window_bounds.y(), 900 + 50 - 10); // -10 to roughly compensate for 239 EXPECT_GT(window_bounds.y(), 900 + 50 - 10); // -10 to roughly compensate for
239 // arrow overlap. 240 // arrow overlap.
240 } 241 }
241 242
243 // Test that the center arrow is moved as needed to fit the screen.
244 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsCenterArrows) {
245 TestBubbleFrameView frame;
246 gfx::Rect window_bounds;
247
248 // Test that the bubble displays normally when it fits.
249 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_CENTER);
250 window_bounds = frame.GetUpdatedWindowBounds(
251 gfx::Rect(500, 100, 50, 50), // |anchor_rect|
252 gfx::Size(500, 500), // |client_size|
253 true); // |adjust_if_offscreen|
254 EXPECT_EQ(BubbleBorder::TOP_CENTER, frame.bubble_border()->arrow_location());
255 EXPECT_EQ(window_bounds.x() + window_bounds.width() / 2, 525);
256
257 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_CENTER);
258 window_bounds = frame.GetUpdatedWindowBounds(
259 gfx::Rect(500, 900, 50, 50), // |anchor_rect|
260 gfx::Size(500, 500), // |client_size|
261 true); // |adjust_if_offscreen|
262 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER,
263 frame.bubble_border()->arrow_location());
264 EXPECT_EQ(window_bounds.x() + window_bounds.width() / 2, 525);
265
266 frame.bubble_border()->set_arrow_location(BubbleBorder::LEFT_CENTER);
267 window_bounds = frame.GetUpdatedWindowBounds(
268 gfx::Rect(100, 400, 50, 50), // |anchor_rect|
269 gfx::Size(500, 500), // |client_size|
270 true); // |adjust_if_offscreen|
271 EXPECT_EQ(BubbleBorder::LEFT_CENTER, frame.bubble_border()->arrow_location());
272 EXPECT_EQ(window_bounds.y() + window_bounds.height() / 2, 425);
273
274 frame.bubble_border()->set_arrow_location(BubbleBorder::RIGHT_CENTER);
275 window_bounds = frame.GetUpdatedWindowBounds(
276 gfx::Rect(900, 400, 50, 50), // |anchor_rect|
277 gfx::Size(500, 500), // |client_size|
278 true); // |adjust_if_offscreen|
279 EXPECT_EQ(BubbleBorder::RIGHT_CENTER,
280 frame.bubble_border()->arrow_location());
281 EXPECT_EQ(window_bounds.y() + window_bounds.height() / 2, 425);
282
283 // Test bubble not fitting left screen edge.
284 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_CENTER);
285 window_bounds = frame.GetUpdatedWindowBounds(
286 gfx::Rect(100, 100, 50, 50), // |anchor_rect|
287 gfx::Size(500, 500), // |client_size|
288 true); // |adjust_if_offscreen|
289 EXPECT_EQ(BubbleBorder::TOP_CENTER, frame.bubble_border()->arrow_location());
290 EXPECT_EQ(window_bounds.x(), 0);
291 EXPECT_GT(window_bounds.x() + window_bounds.width() / 2, 125);
msw 2012/09/20 00:07:23 GT 125 seems too loose, it's EQ 250, right?
xiyuan 2012/09/20 16:56:51 This is intended to verify that bubble's center is
292 EXPECT_EQ(window_bounds.x() +
293 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 125);
294
295 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_CENTER);
296 window_bounds = frame.GetUpdatedWindowBounds(
297 gfx::Rect(100, 900, 50, 50), // |anchor_rect|
298 gfx::Size(500, 500), // |client_size|
299 true); // |adjust_if_offscreen|
300 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER,
301 frame.bubble_border()->arrow_location());
302 EXPECT_EQ(window_bounds.x(), 0);
303 EXPECT_GT(window_bounds.x() + window_bounds.width() / 2, 125);
msw 2012/09/20 00:07:23 ditto: GT 125 seems too loose, it's EQ 250, right?
304 EXPECT_EQ(window_bounds.x() +
305 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 125);
306
307 // Test bubble not fitting right screen edge.
308 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_CENTER);
309 window_bounds = frame.GetUpdatedWindowBounds(
310 gfx::Rect(900, 100, 50, 50), // |anchor_rect|
311 gfx::Size(500, 500), // |client_size|
312 true); // |adjust_if_offscreen|
313 EXPECT_EQ(BubbleBorder::TOP_CENTER, frame.bubble_border()->arrow_location());
314 EXPECT_EQ(window_bounds.right(), 1000);
315 EXPECT_LT(window_bounds.x() + window_bounds.width() / 2, 925);
msw 2012/09/20 00:07:23 similar: LT 925 seems too loose, it's EQ 750, righ
316 EXPECT_EQ(window_bounds.x() +
317 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925);
318
319 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_CENTER);
320 window_bounds = frame.GetUpdatedWindowBounds(
321 gfx::Rect(900, 900, 50, 50), // |anchor_rect|
322 gfx::Size(500, 500), // |client_size|
323 true); // |adjust_if_offscreen|
324 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER,
325 frame.bubble_border()->arrow_location());
326 EXPECT_EQ(window_bounds.right(), 1000);
327 EXPECT_LT(window_bounds.x() + window_bounds.width() / 2, 925);
msw 2012/09/20 00:07:23 ditto: LT 925 seems too loose, it's EQ 750, right?
328 EXPECT_EQ(window_bounds.x() +
329 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925);
330
331 // Test bubble not fitting top screen edge.
332 frame.bubble_border()->set_arrow_location(BubbleBorder::LEFT_CENTER);
333 window_bounds = frame.GetUpdatedWindowBounds(
334 gfx::Rect(100, 100, 50, 50), // |anchor_rect|
335 gfx::Size(500, 500), // |client_size|
336 true); // |adjust_if_offscreen|
337 EXPECT_EQ(BubbleBorder::LEFT_CENTER, frame.bubble_border()->arrow_location());
338 EXPECT_EQ(window_bounds.y(), 0);
339 EXPECT_GT(window_bounds.y() + window_bounds.height() / 2, 125);
msw 2012/09/20 00:07:23 similar: GT 125 seems too loose, it's EQ 250, righ
340 EXPECT_EQ(window_bounds.y() +
341 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 125);
342
343 frame.bubble_border()->set_arrow_location(BubbleBorder::RIGHT_CENTER);
344 window_bounds = frame.GetUpdatedWindowBounds(
345 gfx::Rect(900, 100, 50, 50), // |anchor_rect|
346 gfx::Size(500, 500), // |client_size|
347 true); // |adjust_if_offscreen|
348 EXPECT_EQ(BubbleBorder::RIGHT_CENTER,
349 frame.bubble_border()->arrow_location());
350 EXPECT_EQ(window_bounds.y(), 0);
351 EXPECT_GT(window_bounds.y() + window_bounds.height() / 2, 125);
msw 2012/09/20 00:07:23 ditto: GT 125 seems too loose, it's EQ 250, right?
352 EXPECT_EQ(window_bounds.y() +
353 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 125);
354
355 // Test bubble not fitting bottom screen edge.
356 frame.bubble_border()->set_arrow_location(BubbleBorder::LEFT_CENTER);
357 window_bounds = frame.GetUpdatedWindowBounds(
358 gfx::Rect(100, 900, 50, 50), // |anchor_rect|
359 gfx::Size(500, 500), // |client_size|
360 true); // |adjust_if_offscreen|
361 EXPECT_EQ(BubbleBorder::LEFT_CENTER, frame.bubble_border()->arrow_location());
362 EXPECT_EQ(window_bounds.bottom(), 1000);
363 EXPECT_LT(window_bounds.y() + window_bounds.height() / 2, 925);
msw 2012/09/20 00:07:23 similar: LT 925 seems too loose, it's EQ 750, righ
364 EXPECT_EQ(window_bounds.y() +
365 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925);
366
367 frame.bubble_border()->set_arrow_location(BubbleBorder::RIGHT_CENTER);
368 window_bounds = frame.GetUpdatedWindowBounds(
369 gfx::Rect(900, 900, 50, 50), // |anchor_rect|
370 gfx::Size(500, 500), // |client_size|
371 true); // |adjust_if_offscreen|
372 EXPECT_EQ(BubbleBorder::RIGHT_CENTER,
373 frame.bubble_border()->arrow_location());
374 EXPECT_EQ(window_bounds.bottom(), 1000);
375 EXPECT_LT(window_bounds.y() + window_bounds.height() / 2, 925);
msw 2012/09/20 00:07:23 ditto: LT 925 seems too loose, it's EQ 750, right?
376 EXPECT_EQ(window_bounds.y() +
377 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925);
378 }
379
242 } // namespace views 380 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698