Make castv2 performance test work.
[chromium-blink-merge.git] / ui / views / bubble / bubble_border_unittest.cc
blob404902c323631a7e08fcf24be93cdd482f3ef6be
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
3 // found in the LICENSE file.
5 #include "ui/views/bubble/bubble_border.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/stringprintf.h"
9 #include "ui/views/test/views_test_base.h"
11 namespace views {
13 typedef views::ViewsTestBase BubbleBorderTest;
15 TEST_F(BubbleBorderTest, GetMirroredArrow) {
16 // Horizontal mirroring.
17 EXPECT_EQ(BubbleBorder::TOP_RIGHT,
18 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_LEFT));
19 EXPECT_EQ(BubbleBorder::TOP_LEFT,
20 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_RIGHT));
22 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT,
23 BubbleBorder::horizontal_mirror(BubbleBorder::BOTTOM_LEFT));
24 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT,
25 BubbleBorder::horizontal_mirror(BubbleBorder::BOTTOM_RIGHT));
27 EXPECT_EQ(BubbleBorder::RIGHT_TOP,
28 BubbleBorder::horizontal_mirror(BubbleBorder::LEFT_TOP));
29 EXPECT_EQ(BubbleBorder::LEFT_TOP,
30 BubbleBorder::horizontal_mirror(BubbleBorder::RIGHT_TOP));
32 EXPECT_EQ(BubbleBorder::RIGHT_BOTTOM,
33 BubbleBorder::horizontal_mirror(BubbleBorder::LEFT_BOTTOM));
34 EXPECT_EQ(BubbleBorder::LEFT_BOTTOM,
35 BubbleBorder::horizontal_mirror(BubbleBorder::RIGHT_BOTTOM));
37 EXPECT_EQ(BubbleBorder::TOP_CENTER,
38 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_CENTER));
39 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER,
40 BubbleBorder::horizontal_mirror(BubbleBorder::BOTTOM_CENTER));
42 EXPECT_EQ(BubbleBorder::RIGHT_CENTER,
43 BubbleBorder::horizontal_mirror(BubbleBorder::LEFT_CENTER));
44 EXPECT_EQ(BubbleBorder::LEFT_CENTER,
45 BubbleBorder::horizontal_mirror(BubbleBorder::RIGHT_CENTER));
47 EXPECT_EQ(BubbleBorder::NONE,
48 BubbleBorder::horizontal_mirror(BubbleBorder::NONE));
49 EXPECT_EQ(BubbleBorder::FLOAT,
50 BubbleBorder::horizontal_mirror(BubbleBorder::FLOAT));
52 // Vertical mirroring.
53 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT,
54 BubbleBorder::vertical_mirror(BubbleBorder::TOP_LEFT));
55 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT,
56 BubbleBorder::vertical_mirror(BubbleBorder::TOP_RIGHT));
58 EXPECT_EQ(BubbleBorder::TOP_LEFT,
59 BubbleBorder::vertical_mirror(BubbleBorder::BOTTOM_LEFT));
60 EXPECT_EQ(BubbleBorder::TOP_RIGHT,
61 BubbleBorder::vertical_mirror(BubbleBorder::BOTTOM_RIGHT));
63 EXPECT_EQ(BubbleBorder::LEFT_BOTTOM,
64 BubbleBorder::vertical_mirror(BubbleBorder::LEFT_TOP));
65 EXPECT_EQ(BubbleBorder::RIGHT_BOTTOM,
66 BubbleBorder::vertical_mirror(BubbleBorder::RIGHT_TOP));
68 EXPECT_EQ(BubbleBorder::LEFT_TOP,
69 BubbleBorder::vertical_mirror(BubbleBorder::LEFT_BOTTOM));
70 EXPECT_EQ(BubbleBorder::RIGHT_TOP,
71 BubbleBorder::vertical_mirror(BubbleBorder::RIGHT_BOTTOM));
73 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER,
74 BubbleBorder::vertical_mirror(BubbleBorder::TOP_CENTER));
75 EXPECT_EQ(BubbleBorder::TOP_CENTER,
76 BubbleBorder::vertical_mirror(BubbleBorder::BOTTOM_CENTER));
78 EXPECT_EQ(BubbleBorder::LEFT_CENTER,
79 BubbleBorder::vertical_mirror(BubbleBorder::LEFT_CENTER));
80 EXPECT_EQ(BubbleBorder::RIGHT_CENTER,
81 BubbleBorder::vertical_mirror(BubbleBorder::RIGHT_CENTER));
83 EXPECT_EQ(BubbleBorder::NONE,
84 BubbleBorder::vertical_mirror(BubbleBorder::NONE));
85 EXPECT_EQ(BubbleBorder::FLOAT,
86 BubbleBorder::vertical_mirror(BubbleBorder::FLOAT));
89 TEST_F(BubbleBorderTest, HasArrow) {
90 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::TOP_LEFT));
91 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::TOP_RIGHT));
93 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::BOTTOM_LEFT));
94 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::BOTTOM_RIGHT));
96 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::LEFT_TOP));
97 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::RIGHT_TOP));
99 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::LEFT_BOTTOM));
100 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::RIGHT_BOTTOM));
102 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::TOP_CENTER));
103 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::BOTTOM_CENTER));
105 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::LEFT_CENTER));
106 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::RIGHT_CENTER));
108 EXPECT_FALSE(BubbleBorder::has_arrow(BubbleBorder::NONE));
109 EXPECT_FALSE(BubbleBorder::has_arrow(BubbleBorder::FLOAT));
112 TEST_F(BubbleBorderTest, IsArrowOnLeft) {
113 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::TOP_LEFT));
114 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::TOP_RIGHT));
116 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::BOTTOM_LEFT));
117 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::BOTTOM_RIGHT));
119 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::LEFT_TOP));
120 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::RIGHT_TOP));
122 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::LEFT_BOTTOM));
123 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::RIGHT_BOTTOM));
125 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::TOP_CENTER));
126 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::BOTTOM_CENTER));
128 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::LEFT_CENTER));
129 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::RIGHT_CENTER));
131 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::NONE));
132 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::FLOAT));
135 TEST_F(BubbleBorderTest, IsArrowOnTop) {
136 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::TOP_LEFT));
137 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::TOP_RIGHT));
139 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::BOTTOM_LEFT));
140 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::BOTTOM_RIGHT));
142 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::LEFT_TOP));
143 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::RIGHT_TOP));
145 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::LEFT_BOTTOM));
146 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::RIGHT_BOTTOM));
148 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::TOP_CENTER));
149 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::BOTTOM_CENTER));
151 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::LEFT_CENTER));
152 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::RIGHT_CENTER));
154 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::NONE));
155 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::FLOAT));
158 TEST_F(BubbleBorderTest, IsArrowOnHorizontal) {
159 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::TOP_LEFT));
160 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::TOP_RIGHT));
162 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::BOTTOM_LEFT));
163 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::BOTTOM_RIGHT));
165 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::LEFT_TOP));
166 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::RIGHT_TOP));
168 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::LEFT_BOTTOM));
169 EXPECT_FALSE(
170 BubbleBorder::is_arrow_on_horizontal(BubbleBorder::RIGHT_BOTTOM));
172 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::TOP_CENTER));
173 EXPECT_TRUE(
174 BubbleBorder::is_arrow_on_horizontal(BubbleBorder::BOTTOM_CENTER));
176 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::LEFT_CENTER));
177 EXPECT_FALSE(
178 BubbleBorder::is_arrow_on_horizontal(BubbleBorder::RIGHT_CENTER));
180 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::NONE));
181 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::FLOAT));
184 TEST_F(BubbleBorderTest, IsArrowAtCenter) {
185 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::TOP_LEFT));
186 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::TOP_RIGHT));
188 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_LEFT));
189 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_RIGHT));
191 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_TOP));
192 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_TOP));
194 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_BOTTOM));
195 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_BOTTOM));
197 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::TOP_CENTER));
198 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_CENTER));
200 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_CENTER));
201 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_CENTER));
203 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::NONE));
204 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::FLOAT));
207 TEST_F(BubbleBorderTest, GetSizeForContentsSizeTest) {
208 views::BubbleBorder border(BubbleBorder::NONE,
209 BubbleBorder::NO_SHADOW,
210 SK_ColorWHITE);
212 const views::internal::BorderImages* kImages = border.GetImagesForTest();
214 // kSmallSize is smaller than the minimum allowable size and does not
215 // contribute to the resulting size.
216 const gfx::Size kSmallSize = gfx::Size(1, 2);
217 // kMediumSize is larger than the minimum allowable size and contributes to
218 // the resulting size.
219 const gfx::Size kMediumSize = gfx::Size(50, 60);
221 const gfx::Size kSmallHorizArrow(
222 2 * kImages->border_thickness + kImages->top_arrow.width(),
223 kImages->border_thickness + kImages->arrow_thickness +
224 kImages->border_interior_thickness);
226 const gfx::Size kSmallVertArrow(kSmallHorizArrow.height(),
227 kSmallHorizArrow.width());
229 const gfx::Size kSmallNoArrow(2 * kImages->border_thickness,
230 2 * kImages->border_thickness);
232 const gfx::Size kMediumHorizArrow(
233 kMediumSize.width() + 2 * border.GetBorderThickness(),
234 kMediumSize.height() + border.GetBorderThickness() +
235 kImages->arrow_thickness);
237 const gfx::Size kMediumVertArrow(
238 kMediumSize.width() + border.GetBorderThickness() +
239 kImages->arrow_thickness,
240 kMediumSize.height() + 2 * border.GetBorderThickness());
242 const gfx::Size kMediumNoArrow(
243 kMediumSize.width() + 2 * border.GetBorderThickness(),
244 kMediumSize.height() + 2 * border.GetBorderThickness());
246 struct TestCase {
247 BubbleBorder::Arrow arrow;
248 gfx::Size content;
249 gfx::Size expected_with_arrow;
250 gfx::Size expected_without_arrow;
253 TestCase cases[] = {
254 // Content size: kSmallSize
255 { BubbleBorder::TOP_LEFT, kSmallSize, kSmallHorizArrow, kSmallNoArrow },
256 { BubbleBorder::TOP_CENTER, kSmallSize, kSmallHorizArrow, kSmallNoArrow },
257 { BubbleBorder::TOP_RIGHT, kSmallSize, kSmallHorizArrow, kSmallNoArrow },
258 { BubbleBorder::BOTTOM_LEFT, kSmallSize, kSmallHorizArrow, kSmallNoArrow },
259 { BubbleBorder::BOTTOM_CENTER, kSmallSize, kSmallHorizArrow,
260 kSmallNoArrow },
261 { BubbleBorder::BOTTOM_RIGHT, kSmallSize, kSmallHorizArrow, kSmallNoArrow },
262 { BubbleBorder::LEFT_TOP, kSmallSize, kSmallVertArrow, kSmallNoArrow },
263 { BubbleBorder::LEFT_CENTER, kSmallSize, kSmallVertArrow, kSmallNoArrow },
264 { BubbleBorder::LEFT_BOTTOM, kSmallSize, kSmallVertArrow, kSmallNoArrow },
265 { BubbleBorder::RIGHT_TOP, kSmallSize, kSmallVertArrow, kSmallNoArrow },
266 { BubbleBorder::RIGHT_CENTER, kSmallSize, kSmallVertArrow, kSmallNoArrow },
267 { BubbleBorder::RIGHT_BOTTOM, kSmallSize, kSmallVertArrow, kSmallNoArrow },
268 { BubbleBorder::NONE, kSmallSize, kSmallNoArrow, kSmallNoArrow },
269 { BubbleBorder::FLOAT, kSmallSize, kSmallNoArrow, kSmallNoArrow },
271 // Content size: kMediumSize
272 { BubbleBorder::TOP_LEFT, kMediumSize, kMediumHorizArrow, kMediumNoArrow },
273 { BubbleBorder::TOP_CENTER, kMediumSize, kMediumHorizArrow,
274 kMediumNoArrow },
275 { BubbleBorder::TOP_RIGHT, kMediumSize, kMediumHorizArrow, kMediumNoArrow },
276 { BubbleBorder::BOTTOM_LEFT, kMediumSize, kMediumHorizArrow,
277 kMediumNoArrow },
278 { BubbleBorder::BOTTOM_CENTER, kMediumSize, kMediumHorizArrow,
279 kMediumNoArrow },
280 { BubbleBorder::BOTTOM_RIGHT, kMediumSize, kMediumHorizArrow,
281 kMediumNoArrow },
282 { BubbleBorder::LEFT_TOP, kMediumSize, kMediumVertArrow, kMediumNoArrow },
283 { BubbleBorder::LEFT_CENTER, kMediumSize, kMediumVertArrow,
284 kMediumNoArrow },
285 { BubbleBorder::LEFT_BOTTOM, kMediumSize, kMediumVertArrow,
286 kMediumNoArrow },
287 { BubbleBorder::RIGHT_TOP, kMediumSize, kMediumVertArrow, kMediumNoArrow },
288 { BubbleBorder::RIGHT_CENTER, kMediumSize, kMediumVertArrow,
289 kMediumNoArrow },
290 { BubbleBorder::RIGHT_BOTTOM, kMediumSize, kMediumVertArrow,
291 kMediumNoArrow },
292 { BubbleBorder::NONE, kMediumSize, kMediumNoArrow, kMediumNoArrow },
293 { BubbleBorder::FLOAT, kMediumSize, kMediumNoArrow, kMediumNoArrow }
296 for (size_t i = 0; i < arraysize(cases); ++i) {
297 SCOPED_TRACE(base::StringPrintf("i=%d arrow=%d",
298 static_cast<int>(i), cases[i].arrow));
300 border.set_arrow(cases[i].arrow);
302 border.set_paint_arrow(BubbleBorder::PAINT_NORMAL);
303 EXPECT_EQ(cases[i].expected_with_arrow,
304 border.GetSizeForContentsSize(cases[i].content));
306 border.set_paint_arrow(BubbleBorder::PAINT_TRANSPARENT);
307 EXPECT_EQ(cases[i].expected_with_arrow,
308 border.GetSizeForContentsSize(cases[i].content));
310 border.set_paint_arrow(BubbleBorder::PAINT_NONE);
311 EXPECT_EQ(cases[i].expected_without_arrow,
312 border.GetSizeForContentsSize(cases[i].content));
316 TEST_F(BubbleBorderTest, GetBoundsOriginTest) {
317 views::BubbleBorder border(BubbleBorder::TOP_LEFT,
318 BubbleBorder::NO_SHADOW,
319 SK_ColorWHITE);
321 const gfx::Rect kAnchor(100, 100, 20, 30);
322 const gfx::Size kContentSize(50, 60);
324 const views::internal::BorderImages* kImages = border.GetImagesForTest();
326 border.set_arrow(BubbleBorder::TOP_LEFT);
327 const gfx::Size kTotalSizeWithHorizArrow =
328 border.GetSizeForContentsSize(kContentSize);
330 border.set_arrow(BubbleBorder::RIGHT_BOTTOM);
331 const gfx::Size kTotalSizeWithVertArrow =
332 border.GetSizeForContentsSize(kContentSize);
334 border.set_arrow(BubbleBorder::NONE);
335 const gfx::Size kTotalSizeWithNoArrow =
336 border.GetSizeForContentsSize(kContentSize);
338 const int kBorderThickness = border.GetBorderThickness();
340 const int kArrowOffsetForHorizCenter = kTotalSizeWithHorizArrow.width() / 2;
341 const int kArrowOffsetForVertCenter = kTotalSizeWithVertArrow.height() / 2;
342 const int kArrowOffsetForNotCenter =
343 kImages->border_thickness + (kImages->top_arrow.width() / 2);
345 const int kArrowSize =
346 kImages->arrow_interior_thickness + BubbleBorder::kStroke -
347 kImages->arrow_thickness;
349 const int kTopHorizArrowY = kAnchor.y() + kAnchor.height() + kArrowSize;
350 const int kBottomHorizArrowY =
351 kAnchor.y() - kArrowSize - kTotalSizeWithHorizArrow.height();
353 const int kLeftVertArrowX = kAnchor.x() + kAnchor.width() + kArrowSize;
354 const int kRightVertArrowX =
355 kAnchor.x() - kArrowSize - kTotalSizeWithVertArrow.width();
357 struct TestCase {
358 BubbleBorder::Arrow arrow;
359 BubbleBorder::BubbleAlignment alignment;
360 int expected_x;
361 int expected_y;
364 TestCase cases[] = {
365 // Horizontal arrow tests.
366 { BubbleBorder::TOP_LEFT, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
367 kAnchor.CenterPoint().x() - kArrowOffsetForNotCenter, kTopHorizArrowY },
368 { BubbleBorder::TOP_LEFT, BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE,
369 kAnchor.x() + BubbleBorder::kStroke - kBorderThickness, kTopHorizArrowY },
370 { BubbleBorder::TOP_CENTER, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
371 kAnchor.CenterPoint().x() - kArrowOffsetForHorizCenter, kTopHorizArrowY },
372 { BubbleBorder::BOTTOM_RIGHT, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
373 kAnchor.CenterPoint().x() + kArrowOffsetForNotCenter -
374 kTotalSizeWithHorizArrow.width(), kBottomHorizArrowY },
375 { BubbleBorder::BOTTOM_RIGHT, BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE,
376 kAnchor.x() + kAnchor.width() - kTotalSizeWithHorizArrow.width() +
377 kBorderThickness - BubbleBorder::kStroke, kBottomHorizArrowY },
379 // Vertical arrow tests.
380 { BubbleBorder::LEFT_TOP, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
381 kLeftVertArrowX, kAnchor.CenterPoint().y() - kArrowOffsetForNotCenter },
382 { BubbleBorder::LEFT_TOP, BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE,
383 kLeftVertArrowX, kAnchor.y() + BubbleBorder::kStroke - kBorderThickness },
384 { BubbleBorder::LEFT_CENTER, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
385 kLeftVertArrowX, kAnchor.CenterPoint().y() - kArrowOffsetForVertCenter },
386 { BubbleBorder::RIGHT_BOTTOM, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
387 kRightVertArrowX, kAnchor.CenterPoint().y() + kArrowOffsetForNotCenter -
388 kTotalSizeWithVertArrow.height() },
389 { BubbleBorder::RIGHT_BOTTOM, BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE,
390 kRightVertArrowX, kAnchor.y() + kAnchor.height() -
391 kTotalSizeWithVertArrow.height() + kBorderThickness -
392 BubbleBorder::kStroke },
394 // No arrow tests.
395 { BubbleBorder::NONE, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
396 kAnchor.x() + (kAnchor.width() - kTotalSizeWithNoArrow.width()) / 2,
397 kAnchor.y() + kAnchor.height() },
398 { BubbleBorder::FLOAT, BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR,
399 kAnchor.x() + (kAnchor.width() - kTotalSizeWithNoArrow.width()) / 2,
400 kAnchor.y() + (kAnchor.height() - kTotalSizeWithNoArrow.height()) / 2 },
403 for (size_t i = 0; i < arraysize(cases); ++i) {
404 SCOPED_TRACE(base::StringPrintf("i=%d arrow=%d alignment=%d",
405 static_cast<int>(i), cases[i].arrow, cases[i].alignment));
406 border.set_arrow(cases[i].arrow);
407 border.set_alignment(cases[i].alignment);
409 gfx::Point origin = border.GetBounds(kAnchor, kContentSize).origin();
410 EXPECT_EQ(cases[i].expected_x, origin.x());
411 EXPECT_EQ(cases[i].expected_y, origin.y());
415 } // namespace views