Home | History | Annotate | Download | only in bubble
      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.
      4 
      5 #include "ui/views/bubble/bubble_border.h"
      6 
      7 #include "base/memory/scoped_ptr.h"
      8 #include "base/strings/stringprintf.h"
      9 #include "ui/views/test/views_test_base.h"
     10 
     11 namespace views {
     12 
     13 typedef views::ViewsTestBase BubbleBorderTest;
     14 
     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));
     21 
     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));
     26 
     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));
     31 
     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));
     36 
     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));
     41 
     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));
     46 
     47   EXPECT_EQ(BubbleBorder::NONE,
     48             BubbleBorder::horizontal_mirror(BubbleBorder::NONE));
     49   EXPECT_EQ(BubbleBorder::FLOAT,
     50             BubbleBorder::horizontal_mirror(BubbleBorder::FLOAT));
     51 
     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));
     57 
     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));
     62 
     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));
     67 
     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));
     72 
     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));
     77 
     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));
     82 
     83   EXPECT_EQ(BubbleBorder::NONE,
     84             BubbleBorder::vertical_mirror(BubbleBorder::NONE));
     85   EXPECT_EQ(BubbleBorder::FLOAT,
     86             BubbleBorder::vertical_mirror(BubbleBorder::FLOAT));
     87 }
     88 
     89 TEST_F(BubbleBorderTest, HasArrow) {
     90   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::TOP_LEFT));
     91   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::TOP_RIGHT));
     92 
     93   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::BOTTOM_LEFT));
     94   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::BOTTOM_RIGHT));
     95 
     96   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::LEFT_TOP));
     97   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::RIGHT_TOP));
     98 
     99   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::LEFT_BOTTOM));
    100   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::RIGHT_BOTTOM));
    101 
    102   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::TOP_CENTER));
    103   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::BOTTOM_CENTER));
    104 
    105   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::LEFT_CENTER));
    106   EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::RIGHT_CENTER));
    107 
    108   EXPECT_FALSE(BubbleBorder::has_arrow(BubbleBorder::NONE));
    109   EXPECT_FALSE(BubbleBorder::has_arrow(BubbleBorder::FLOAT));
    110 }
    111 
    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));
    115 
    116   EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::BOTTOM_LEFT));
    117   EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::BOTTOM_RIGHT));
    118 
    119   EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::LEFT_TOP));
    120   EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::RIGHT_TOP));
    121 
    122   EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::LEFT_BOTTOM));
    123   EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::RIGHT_BOTTOM));
    124 
    125   EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::TOP_CENTER));
    126   EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::BOTTOM_CENTER));
    127 
    128   EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::LEFT_CENTER));
    129   EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::RIGHT_CENTER));
    130 
    131   EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::NONE));
    132   EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::FLOAT));
    133 }
    134 
    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));
    138 
    139   EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::BOTTOM_LEFT));
    140   EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::BOTTOM_RIGHT));
    141 
    142   EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::LEFT_TOP));
    143   EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::RIGHT_TOP));
    144 
    145   EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::LEFT_BOTTOM));
    146   EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::RIGHT_BOTTOM));
    147 
    148   EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::TOP_CENTER));
    149   EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::BOTTOM_CENTER));
    150 
    151   EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::LEFT_CENTER));
    152   EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::RIGHT_CENTER));
    153 
    154   EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::NONE));
    155   EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::FLOAT));
    156 }
    157 
    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));
    161 
    162   EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::BOTTOM_LEFT));
    163   EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::BOTTOM_RIGHT));
    164 
    165   EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::LEFT_TOP));
    166   EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::RIGHT_TOP));
    167 
    168   EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::LEFT_BOTTOM));
    169   EXPECT_FALSE(
    170       BubbleBorder::is_arrow_on_horizontal(BubbleBorder::RIGHT_BOTTOM));
    171 
    172   EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::TOP_CENTER));
    173   EXPECT_TRUE(
    174       BubbleBorder::is_arrow_on_horizontal(BubbleBorder::BOTTOM_CENTER));
    175 
    176   EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::LEFT_CENTER));
    177   EXPECT_FALSE(
    178       BubbleBorder::is_arrow_on_horizontal(BubbleBorder::RIGHT_CENTER));
    179 
    180   EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::NONE));
    181   EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::FLOAT));
    182 }
    183 
    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));
    187 
    188   EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_LEFT));
    189   EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_RIGHT));
    190 
    191   EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_TOP));
    192   EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_TOP));
    193 
    194   EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_BOTTOM));
    195   EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_BOTTOM));
    196 
    197   EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::TOP_CENTER));
    198   EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_CENTER));
    199 
    200   EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_CENTER));
    201   EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_CENTER));
    202 
    203   EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::NONE));
    204   EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::FLOAT));
    205 }
    206 
    207 TEST_F(BubbleBorderTest, GetSizeForContentsSizeTest) {
    208   views::BubbleBorder border(BubbleBorder::NONE,
    209                              BubbleBorder::NO_SHADOW,
    210                              SK_ColorWHITE);
    211 
    212   const views::internal::BorderImages* kImages = border.GetImagesForTest();
    213 
    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);
    220 
    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);
    225 
    226   const gfx::Size kSmallVertArrow(kSmallHorizArrow.height(),
    227                                   kSmallHorizArrow.width());
    228 
    229   const gfx::Size kSmallNoArrow(2 * kImages->border_thickness,
    230                                 2 * kImages->border_thickness);
    231 
    232   const gfx::Size kMediumHorizArrow(
    233       kMediumSize.width() + 2 * border.GetBorderThickness(),
    234       kMediumSize.height() + border.GetBorderThickness() +
    235           kImages->arrow_thickness);
    236 
    237   const gfx::Size kMediumVertArrow(
    238       kMediumSize.width() + border.GetBorderThickness() +
    239           kImages->arrow_thickness,
    240       kMediumSize.height() + 2 * border.GetBorderThickness());
    241 
    242   const gfx::Size kMediumNoArrow(
    243       kMediumSize.width() + 2 * border.GetBorderThickness(),
    244       kMediumSize.height() + 2 * border.GetBorderThickness());
    245 
    246   struct TestCase {
    247     BubbleBorder::Arrow arrow;
    248     gfx::Size content;
    249     gfx::Size expected_with_arrow;
    250     gfx::Size expected_without_arrow;
    251   };
    252 
    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 },
    270 
    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 }
    294   };
    295 
    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));
    299 
    300     border.set_arrow(cases[i].arrow);
    301 
    302     border.set_paint_arrow(BubbleBorder::PAINT_NORMAL);
    303     EXPECT_EQ(cases[i].expected_with_arrow,
    304               border.GetSizeForContentsSize(cases[i].content));
    305 
    306     border.set_paint_arrow(BubbleBorder::PAINT_TRANSPARENT);
    307     EXPECT_EQ(cases[i].expected_with_arrow,
    308               border.GetSizeForContentsSize(cases[i].content));
    309 
    310     border.set_paint_arrow(BubbleBorder::PAINT_NONE);
    311     EXPECT_EQ(cases[i].expected_without_arrow,
    312               border.GetSizeForContentsSize(cases[i].content));
    313   }
    314 }
    315 
    316 TEST_F(BubbleBorderTest, GetBoundsOriginTest) {
    317   views::BubbleBorder border(BubbleBorder::TOP_LEFT,
    318                              BubbleBorder::NO_SHADOW,
    319                              SK_ColorWHITE);
    320 
    321   const gfx::Rect kAnchor(100, 100, 20, 30);
    322   const gfx::Size kContentSize(50, 60);
    323 
    324   const views::internal::BorderImages* kImages = border.GetImagesForTest();
    325 
    326   border.set_arrow(BubbleBorder::TOP_LEFT);
    327   const gfx::Size kTotalSizeWithHorizArrow =
    328       border.GetSizeForContentsSize(kContentSize);
    329 
    330   border.set_arrow(BubbleBorder::RIGHT_BOTTOM);
    331   const gfx::Size kTotalSizeWithVertArrow =
    332       border.GetSizeForContentsSize(kContentSize);
    333 
    334   border.set_arrow(BubbleBorder::NONE);
    335   const gfx::Size kTotalSizeWithNoArrow =
    336       border.GetSizeForContentsSize(kContentSize);
    337 
    338   const int kBorderThickness = border.GetBorderThickness();
    339 
    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);
    344 
    345   const int kArrowSize =
    346       kImages->arrow_interior_thickness + BubbleBorder::kStroke -
    347           kImages->arrow_thickness;
    348 
    349   const int kTopHorizArrowY = kAnchor.y() + kAnchor.height() + kArrowSize;
    350   const int kBottomHorizArrowY =
    351       kAnchor.y() - kArrowSize - kTotalSizeWithHorizArrow.height();
    352 
    353   const int kLeftVertArrowX = kAnchor.x() + kAnchor.width() + kArrowSize;
    354   const int kRightVertArrowX =
    355       kAnchor.x() - kArrowSize - kTotalSizeWithVertArrow.width();
    356 
    357   struct TestCase {
    358     BubbleBorder::Arrow arrow;
    359     BubbleBorder::BubbleAlignment alignment;
    360     int expected_x;
    361     int expected_y;
    362   };
    363 
    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 },
    378 
    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 },
    393 
    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 },
    401   };
    402 
    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);
    408 
    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());
    412   }
    413 }
    414 
    415 }  // namespace views
    416