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 #include "ui/views/bubble/bubble_border.h" | 5 #include "ui/views/bubble/bubble_border.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | |
8 #include "base/strings/stringprintf.h" | |
7 #include "ui/views/test/views_test_base.h" | 9 #include "ui/views/test/views_test_base.h" |
8 | 10 |
9 namespace views { | 11 namespace views { |
10 | 12 |
11 typedef ViewsTestBase BubbleBorderTest; | 13 class BubbleBorderTest : public views::ViewsTestBase { |
msw
2014/08/22 20:54:45
Change this subclass to a typedef.
bruthig
2014/08/22 22:55:03
Done.
| |
14 public: | |
15 const int kStroke = views::BubbleBorder::kStroke; | |
msw
2014/08/22 20:54:45
Have GetBoundsOriginTest grab this instead.
bruthig
2014/08/22 22:55:03
Done.
| |
16 | |
17 BubbleBorderTest() {} | |
18 virtual ~BubbleBorderTest() {} | |
19 | |
20 private: | |
21 DISALLOW_COPY_AND_ASSIGN(BubbleBorderTest); | |
22 }; | |
23 | |
24 typedef BubbleBorderTest BubbleBorderGetBoundsOriginTest; | |
msw
2014/08/22 20:54:45
Remove this.
bruthig
2014/08/22 22:55:03
Done.
| |
12 | 25 |
13 TEST_F(BubbleBorderTest, GetMirroredArrow) { | 26 TEST_F(BubbleBorderTest, GetMirroredArrow) { |
14 // Horizontal mirroring. | 27 // Horizontal mirroring. |
15 EXPECT_EQ(BubbleBorder::TOP_RIGHT, | 28 EXPECT_EQ(BubbleBorder::TOP_RIGHT, |
16 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_LEFT)); | 29 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_LEFT)); |
17 EXPECT_EQ(BubbleBorder::TOP_LEFT, | 30 EXPECT_EQ(BubbleBorder::TOP_LEFT, |
18 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_RIGHT)); | 31 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_RIGHT)); |
19 | 32 |
20 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT, | 33 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT, |
21 BubbleBorder::horizontal_mirror(BubbleBorder::BOTTOM_LEFT)); | 34 BubbleBorder::horizontal_mirror(BubbleBorder::BOTTOM_LEFT)); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::TOP_CENTER)); | 208 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::TOP_CENTER)); |
196 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_CENTER)); | 209 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_CENTER)); |
197 | 210 |
198 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_CENTER)); | 211 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_CENTER)); |
199 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_CENTER)); | 212 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_CENTER)); |
200 | 213 |
201 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::NONE)); | 214 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::NONE)); |
202 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::FLOAT)); | 215 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::FLOAT)); |
203 } | 216 } |
204 | 217 |
205 TEST_F(BubbleBorderTest, TestMinimalSize) { | 218 TEST_F(BubbleBorderTest, GetSizeForContentsSizeTest) { |
206 gfx::Rect anchor = gfx::Rect(100, 100, 20, 20); | 219 views::BubbleBorder bb(BubbleBorder::NONE, |
msw
2014/08/22 20:54:45
nit: abbreviations are discouraged, consider |bord
bruthig
2014/08/22 22:55:03
Done.
| |
207 gfx::Size contents = gfx::Size(10, 10); | 220 BubbleBorder::NO_SHADOW, |
208 BubbleBorder b1(BubbleBorder::RIGHT_TOP, BubbleBorder::NO_SHADOW, 0); | 221 SK_ColorWHITE); |
209 | 222 |
210 // The height should be much bigger then the requested size + border and | 223 const views::internal::BorderImages* kImages = bb.GetImagesForTest(); |
211 // padding since it needs to be able to include the tip bitmap. | 224 |
212 gfx::Rect visible_tip_1 = b1.GetBounds(anchor, contents); | 225 const gfx::Size kSmallSize = gfx::Size(1, 1); |
213 EXPECT_GE(visible_tip_1.height(), 30); | 226 const gfx::Size kMediumSize = gfx::Size(50, 50); |
214 EXPECT_LE(visible_tip_1.width(), 30); | 227 const gfx::Rect kAnchor = gfx::Rect(100, 100, 20, 20); |
215 | 228 |
216 // With the tip being invisible the height should now be much smaller. | 229 const gfx::Size kSmallHorizArrow( |
217 b1.set_paint_arrow(BubbleBorder::PAINT_TRANSPARENT); | 230 2 * kImages->border_thickness + kImages->top_arrow.width(), |
218 gfx::Rect invisible_tip_1 = b1.GetBounds(anchor, contents); | 231 kImages->border_thickness + kImages->arrow_thickness + |
219 EXPECT_LE(invisible_tip_1.height(), 30); | 232 kImages->border_interior_thickness); |
msw
2014/08/22 20:54:45
nit: indent two more spaces.
bruthig
2014/08/22 22:55:04
Done.
| |
220 EXPECT_LE(invisible_tip_1.width(), 30); | 233 |
221 | 234 const gfx::Size kSmallVertArrow( |
msw
2014/08/22 20:54:45
nit: Since the content sizes are square, could thi
bruthig
2014/08/22 22:55:03
Actually I meant to change those sizes so they are
| |
222 // When the orientation of the tip changes, the above mentioned tests need to | 235 kImages->border_thickness + kImages->arrow_thickness |
223 // be reverse for width and height. | 236 + kImages->border_interior_thickness, |
msw
2014/08/22 20:54:45
nit: move '+' to line above, indent two more space
bruthig
2014/08/22 22:55:03
Done.
| |
224 BubbleBorder b2(BubbleBorder::TOP_RIGHT, BubbleBorder::NO_SHADOW, 0); | 237 2 * kImages->border_thickness + kImages->top_arrow.width()); |
225 | 238 |
226 // The width should be much bigger then the requested size + border and | 239 const gfx::Size kSmallNoArrow(2 * kImages->border_thickness, |
227 // padding since it needs to be able to include the tip bitmap. | 240 2 * kImages->border_thickness); |
228 gfx::Rect visible_tip_2 = b2.GetBounds(anchor, contents); | 241 |
229 EXPECT_GE(visible_tip_2.width(), 30); | 242 const gfx::Size kMediumHorizArrow( |
230 EXPECT_LE(visible_tip_2.height(), 30); | 243 kMediumSize.width() + 2 * bb.GetBorderThickness(), |
msw
2014/08/22 20:54:45
Are the medium/small calculations different becaus
bruthig
2014/08/22 22:55:03
Done.
| |
231 | 244 kMediumSize.height() + bb.GetBorderThickness() |
232 // With the tip being invisible the width should now be much smaller. | 245 + kImages->arrow_thickness); |
msw
2014/08/22 20:54:45
nit: move '+' to line above, indent two more space
bruthig
2014/08/22 22:55:03
Done.
| |
233 b2.set_paint_arrow(BubbleBorder::PAINT_TRANSPARENT); | 246 |
234 gfx::Rect invisible_tip_2 = b2.GetBounds(anchor, contents); | 247 const gfx::Size kMediumVertArrow( |
235 EXPECT_LE(invisible_tip_2.width(), 30); | 248 kMediumSize.width() + bb.GetBorderThickness() + kImages->arrow_thickness, |
236 EXPECT_LE(invisible_tip_2.height(), 30); | 249 kMediumSize.height() + 2 * bb.GetBorderThickness()); |
250 | |
251 const gfx::Size kMediumNoArrow( | |
252 kMediumSize.width() + 2 * bb.GetBorderThickness(), | |
253 kMediumSize.width() + 2 * bb.GetBorderThickness()); | |
254 | |
255 struct TestCase { | |
256 BubbleBorder::Arrow arrow; | |
257 bool has_arrow; | |
msw
2014/08/22 20:54:44
Remove this and the check; BubbleBorderTest.HasArr
bruthig
2014/08/22 22:55:03
Done.
| |
258 BubbleBorder::ArrowPaintType paint_arrow; | |
259 gfx::Size content; | |
260 gfx::Size expected; | |
261 }; | |
262 | |
263 TestCase cases[] = { | |
264 // Content size: kSmallSize | |
265 | |
266 // BubbleBorder::Arrow::TOP_CENTER | |
msw
2014/08/22 20:54:44
nit: Remove these comments; they aren't as helpful
bruthig
2014/08/22 22:55:03
Done.
| |
267 {BubbleBorder::TOP_CENTER, true, BubbleBorder::PAINT_NORMAL, | |
msw
2014/08/22 20:54:44
nit: Sorry for iterating on my earlier suggested d
bruthig
2014/08/22 22:55:03
Done.
| |
268 kSmallSize, kSmallHorizArrow}, | |
269 {BubbleBorder::TOP_CENTER, true, BubbleBorder::PAINT_TRANSPARENT, | |
msw
2014/08/22 20:54:45
nit: use spaces inside of curly braces.
bruthig
2014/08/22 22:55:04
Done.
| |
270 kSmallSize, kSmallHorizArrow}, | |
271 {BubbleBorder::TOP_CENTER, true, BubbleBorder::PAINT_NONE, | |
272 kSmallSize, kSmallNoArrow}, | |
273 | |
274 // BubbleBorder::Arrow::BOTTOM_CENTER | |
275 {BubbleBorder::BOTTOM_CENTER, true, BubbleBorder::PAINT_NORMAL, | |
276 kSmallSize, kSmallHorizArrow}, | |
277 {BubbleBorder::BOTTOM_CENTER, true, BubbleBorder::PAINT_TRANSPARENT, | |
278 kSmallSize, kSmallHorizArrow}, | |
279 {BubbleBorder::BOTTOM_CENTER, true, BubbleBorder::PAINT_NONE, | |
280 kSmallSize, kSmallNoArrow}, | |
281 | |
282 // BubbleBorder::Arrow::LEFT_TOP | |
283 {BubbleBorder::LEFT_TOP, true, BubbleBorder::PAINT_NORMAL, | |
284 kSmallSize, kSmallVertArrow}, | |
285 {BubbleBorder::LEFT_TOP, true, BubbleBorder::PAINT_TRANSPARENT, | |
286 kSmallSize, kSmallVertArrow}, | |
287 {BubbleBorder::LEFT_TOP, true, BubbleBorder::PAINT_NONE, | |
288 kSmallSize, kSmallNoArrow}, | |
289 | |
290 // BubbleBorder::Arrow::RIGHT_TOP | |
291 {BubbleBorder::RIGHT_TOP, true, BubbleBorder::PAINT_NORMAL, | |
292 kSmallSize, kSmallVertArrow}, | |
293 {BubbleBorder::RIGHT_TOP, true, BubbleBorder::PAINT_TRANSPARENT, | |
294 kSmallSize, kSmallVertArrow}, | |
295 {BubbleBorder::RIGHT_TOP, true, BubbleBorder::PAINT_NONE, | |
296 kSmallSize, kSmallNoArrow}, | |
297 | |
298 // BubbleBorder::Arrow::NONE | |
299 {BubbleBorder::NONE, false, BubbleBorder::PAINT_NORMAL, | |
300 kSmallSize, kSmallNoArrow}, | |
301 {BubbleBorder::NONE, false, BubbleBorder::PAINT_TRANSPARENT, | |
302 kSmallSize, kSmallNoArrow}, | |
303 {BubbleBorder::NONE, false, BubbleBorder::PAINT_NONE, | |
304 kSmallSize, kSmallNoArrow}, | |
305 | |
306 // BubbleBorder::Arrow::FLOAT | |
307 {BubbleBorder::FLOAT, false, BubbleBorder::PAINT_NORMAL, | |
308 kSmallSize, kSmallNoArrow}, | |
309 {BubbleBorder::FLOAT, false, BubbleBorder::PAINT_TRANSPARENT, | |
310 kSmallSize, kSmallNoArrow}, | |
311 {BubbleBorder::FLOAT, false, BubbleBorder::PAINT_NONE, | |
312 kSmallSize, kSmallNoArrow}, | |
313 | |
314 // Content size: kMediumSize | |
315 | |
316 // BubbleBorder::Arrow::TOP_CENTER | |
317 {BubbleBorder::TOP_CENTER, true, BubbleBorder::PAINT_NORMAL, | |
318 kMediumSize, kMediumHorizArrow}, | |
319 {BubbleBorder::TOP_CENTER, true, BubbleBorder::PAINT_TRANSPARENT, | |
320 kMediumSize, kMediumHorizArrow}, | |
321 {BubbleBorder::TOP_CENTER, true, BubbleBorder::PAINT_NONE, | |
322 kMediumSize, kMediumNoArrow}, | |
323 | |
324 // BubbleBorder::Arrow::BOTTOM_CENTER | |
325 {BubbleBorder::BOTTOM_CENTER, true, BubbleBorder::PAINT_NORMAL, | |
326 kMediumSize, kMediumHorizArrow}, | |
327 {BubbleBorder::BOTTOM_CENTER, true, BubbleBorder::PAINT_TRANSPARENT, | |
328 kMediumSize, kMediumHorizArrow}, | |
329 {BubbleBorder::BOTTOM_CENTER, true, BubbleBorder::PAINT_NONE, | |
330 kMediumSize, kMediumNoArrow}, | |
331 | |
332 // BubbleBorder::Arrow::LEFT_TOP | |
333 {BubbleBorder::LEFT_TOP, true, BubbleBorder::PAINT_NORMAL, | |
334 kMediumSize, kMediumVertArrow}, | |
335 {BubbleBorder::LEFT_TOP, true, BubbleBorder::PAINT_TRANSPARENT, | |
336 kMediumSize, kMediumVertArrow}, | |
337 {BubbleBorder::LEFT_TOP, true, BubbleBorder::PAINT_NONE, | |
338 kMediumSize, kMediumNoArrow}, | |
339 | |
340 // BubbleBorder::Arrow::RIGHT_TOP | |
341 {BubbleBorder::RIGHT_TOP, true, BubbleBorder::PAINT_NORMAL, | |
342 kMediumSize, kMediumVertArrow}, | |
343 {BubbleBorder::RIGHT_TOP, true, BubbleBorder::PAINT_TRANSPARENT, | |
344 kMediumSize, kMediumVertArrow}, | |
345 {BubbleBorder::RIGHT_TOP, true, BubbleBorder::PAINT_NONE, | |
346 kMediumSize, kMediumNoArrow}, | |
347 | |
348 // BubbleBorder::Arrow::NONE | |
349 {BubbleBorder::NONE, false, BubbleBorder::PAINT_NORMAL, | |
350 kMediumSize, kMediumNoArrow}, | |
351 {BubbleBorder::NONE, false, BubbleBorder::PAINT_TRANSPARENT, | |
352 kMediumSize, kMediumNoArrow}, | |
353 {BubbleBorder::NONE, false, BubbleBorder::PAINT_NONE, | |
354 kMediumSize, kMediumNoArrow}, | |
355 | |
356 // BubbleBorder::Arrow::FLOAT | |
357 {BubbleBorder::FLOAT, false, BubbleBorder::PAINT_NORMAL, | |
358 kMediumSize, kMediumNoArrow}, | |
359 {BubbleBorder::FLOAT, false, BubbleBorder::PAINT_TRANSPARENT, | |
360 kMediumSize, kMediumNoArrow}, | |
361 {BubbleBorder::FLOAT, false, BubbleBorder::PAINT_NONE, | |
362 kMediumSize, kMediumNoArrow} | |
363 }; | |
364 | |
365 for (size_t i = 0; i < arraysize(cases); ++i) { | |
366 SCOPED_TRACE(base::StringPrintf("i=%d arrow=%d paint_arrow=%d", | |
367 static_cast<int>(i), cases[i].arrow, cases[i].paint_arrow)); | |
368 | |
369 bb.set_arrow(cases[i].arrow); | |
370 ASSERT_EQ(cases[i].has_arrow, BubbleBorder::has_arrow(bb.arrow())); | |
371 bb.set_paint_arrow(cases[i].paint_arrow); | |
372 | |
373 EXPECT_EQ(cases[i].expected, | |
374 bb.GetSizeForContentsSize(cases[i].content)); | |
375 } | |
237 } | 376 } |
238 | 377 |
378 TEST_F(BubbleBorderTest, GetBoundsOriginTest) { | |
379 views::BubbleBorder bb(BubbleBorder::TOP_LEFT, | |
msw
2014/08/22 20:54:45
ditto nit: |border|
bruthig
2014/08/22 22:55:03
Done.
| |
380 BubbleBorder::NO_SHADOW, | |
381 SK_ColorWHITE); | |
382 | |
383 const gfx::Rect kAnchor(100, 100, 20, 20); | |
384 const gfx::Size kContentSize(50, 50); | |
385 | |
386 const views::internal::BorderImages* kImages = bb.GetImagesForTest(); | |
387 | |
388 bb.set_arrow(BubbleBorder::TOP_LEFT); | |
389 const gfx::Size kTotalSizeWithHorizArrow = | |
390 bb.GetSizeForContentsSize(kContentSize); | |
391 | |
392 bb.set_arrow(BubbleBorder::RIGHT_BOTTOM); | |
393 const gfx::Size kTotalSizeWithVertArrow = | |
394 bb.GetSizeForContentsSize(kContentSize); | |
395 | |
396 bb.set_arrow(BubbleBorder::NONE); | |
397 const gfx::Size kTotalSizeWithNoArrow = | |
398 bb.GetSizeForContentsSize(kContentSize); | |
399 | |
400 const int kBorderThickness = bb.GetBorderThickness(); | |
401 | |
402 const int kMidAnchorWidth = kAnchor.width() / 2; | |
403 const int kMidAnchorHeight = kAnchor.height() / 2; | |
404 | |
405 const int kArrowOffsetForHorizCentre = kTotalSizeWithHorizArrow.width() / 2; | |
msw
2014/08/22 20:54:45
nit: use the EN-US spelling "Center"
bruthig
2014/08/22 22:55:03
Done.
| |
406 const int kArrowOffsetForVertCentre = kTotalSizeWithVertArrow.height() / 2; | |
407 const int kArrowOffsetForNotCentre = | |
408 kImages->border_thickness + (kImages->top_arrow.width() / 2); | |
409 | |
410 const int kArrowSize = | |
411 kImages->arrow_interior_thickness + kStroke - kImages->arrow_thickness; | |
412 | |
413 const int kTopHorizArrowY = kAnchor.y() + kAnchor.height() + kArrowSize; | |
414 const int kBottomHorizArrowY = | |
415 kAnchor.y() - kArrowSize - kTotalSizeWithHorizArrow.height(); | |
416 | |
417 const int kLeftVertArrowX = kAnchor.x() + kAnchor.width() + kArrowSize; | |
418 const int kRightVertArrowX = | |
419 kAnchor.x() - kArrowSize - kTotalSizeWithVertArrow.width(); | |
420 | |
421 struct TestCase { | |
422 BubbleBorder::Arrow arrow; | |
423 BubbleBorder::BubbleAlignment alignment; | |
424 int expectedX; | |
425 int expectedY; | |
426 }; | |
427 | |
428 TestCase cases[] = { | |
msw
2014/08/22 20:54:45
Ditto, if you see some way to simplify this test,
bruthig
2014/08/22 22:55:03
The existing tests exhaust all the code paths thro
| |
429 // Horizontal arrow tests. | |
430 {BubbleBorder::TOP_LEFT, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
msw
2014/08/22 20:54:44
ditto nit: spaces inside braces.
bruthig
2014/08/22 22:55:03
Done.
| |
431 kAnchor.x() + kMidAnchorWidth - kArrowOffsetForNotCentre, | |
432 kTopHorizArrowY}, | |
433 {BubbleBorder::TOP_LEFT, BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, | |
434 kAnchor.x() + kStroke - kBorderThickness, | |
435 kTopHorizArrowY}, | |
436 {BubbleBorder::TOP_CENTER, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
437 kAnchor.x() + kMidAnchorWidth - kArrowOffsetForHorizCentre, | |
438 kTopHorizArrowY}, | |
439 {BubbleBorder::BOTTOM_RIGHT, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
440 kAnchor.x() + kMidAnchorWidth + kArrowOffsetForNotCentre | |
441 - kTotalSizeWithHorizArrow.width(), | |
442 kBottomHorizArrowY}, | |
443 {BubbleBorder::BOTTOM_RIGHT, BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, | |
444 kAnchor.x() + kAnchor.width() - kTotalSizeWithHorizArrow.width() | |
445 + kBorderThickness - kStroke, | |
446 kBottomHorizArrowY}, | |
447 | |
448 // Vertical arrow tests. | |
449 {BubbleBorder::LEFT_TOP, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
450 kLeftVertArrowX, | |
451 kAnchor.y() + kMidAnchorHeight - kArrowOffsetForNotCentre}, | |
452 {BubbleBorder::LEFT_TOP, BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, | |
453 kLeftVertArrowX, | |
454 kAnchor.y() + kStroke - kBorderThickness}, | |
455 {BubbleBorder::LEFT_CENTER, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
456 kLeftVertArrowX, | |
457 kAnchor.y() + kMidAnchorHeight - kArrowOffsetForVertCentre}, | |
458 {BubbleBorder::RIGHT_BOTTOM, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
459 kRightVertArrowX, | |
460 kAnchor.y() + kMidAnchorHeight + kArrowOffsetForNotCentre | |
461 - kTotalSizeWithVertArrow.height()}, | |
462 {BubbleBorder::RIGHT_BOTTOM, BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, | |
463 kRightVertArrowX, | |
464 kAnchor.y() + kAnchor.height() - kTotalSizeWithVertArrow.height() | |
465 + kBorderThickness - kStroke}, | |
466 | |
467 // No arrow tests. | |
468 {BubbleBorder::NONE, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
469 kAnchor.x() + (kAnchor.width() - kTotalSizeWithNoArrow.width()) / 2, | |
470 kAnchor.y() + kAnchor.height()}, | |
471 {BubbleBorder::FLOAT, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
472 kAnchor.x() + (kAnchor.width() - kTotalSizeWithNoArrow.width()) / 2, | |
473 kAnchor.y() + (kAnchor.height() - kTotalSizeWithNoArrow.height()) / 2}, | |
474 }; | |
475 | |
476 for (size_t i = 0; i < arraysize(cases); ++i) { | |
477 SCOPED_TRACE(base::StringPrintf("i=%d arrow=%d alignment=%d", | |
478 static_cast<int>(i), cases[i].arrow, cases[i].alignment)); | |
479 bb.set_arrow(cases[i].arrow); | |
480 bb.set_alignment(cases[i].alignment); | |
481 | |
482 gfx::Point origin = bb.GetBounds(kAnchor, kContentSize).origin(); | |
483 EXPECT_EQ(cases[i].expectedX, origin.x()); | |
484 EXPECT_EQ(cases[i].expectedY, origin.y()); | |
485 } | |
486 } | |
239 | 487 |
240 } // namespace views | 488 } // namespace views |
OLD | NEW |