Demonstrate the basic functionality of the File System
[chromium-blink-merge.git] / ui / views / bubble / bubble_border_unittest.cc
blobb8838f656ba177e70a6cac271754729b726c250b
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 "ui/views/test/views_test_base.h"
9 namespace views {
11 typedef ViewsTestBase BubbleBorderTest;
13 TEST_F(BubbleBorderTest, GetMirroredArrow) {
14 // Horizontal mirroring.
15 EXPECT_EQ(BubbleBorder::TOP_RIGHT,
16 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_LEFT));
17 EXPECT_EQ(BubbleBorder::TOP_LEFT,
18 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_RIGHT));
20 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT,
21 BubbleBorder::horizontal_mirror(BubbleBorder::BOTTOM_LEFT));
22 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT,
23 BubbleBorder::horizontal_mirror(BubbleBorder::BOTTOM_RIGHT));
25 EXPECT_EQ(BubbleBorder::RIGHT_TOP,
26 BubbleBorder::horizontal_mirror(BubbleBorder::LEFT_TOP));
27 EXPECT_EQ(BubbleBorder::LEFT_TOP,
28 BubbleBorder::horizontal_mirror(BubbleBorder::RIGHT_TOP));
30 EXPECT_EQ(BubbleBorder::RIGHT_BOTTOM,
31 BubbleBorder::horizontal_mirror(BubbleBorder::LEFT_BOTTOM));
32 EXPECT_EQ(BubbleBorder::LEFT_BOTTOM,
33 BubbleBorder::horizontal_mirror(BubbleBorder::RIGHT_BOTTOM));
35 EXPECT_EQ(BubbleBorder::TOP_CENTER,
36 BubbleBorder::horizontal_mirror(BubbleBorder::TOP_CENTER));
37 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER,
38 BubbleBorder::horizontal_mirror(BubbleBorder::BOTTOM_CENTER));
40 EXPECT_EQ(BubbleBorder::RIGHT_CENTER,
41 BubbleBorder::horizontal_mirror(BubbleBorder::LEFT_CENTER));
42 EXPECT_EQ(BubbleBorder::LEFT_CENTER,
43 BubbleBorder::horizontal_mirror(BubbleBorder::RIGHT_CENTER));
45 EXPECT_EQ(BubbleBorder::NONE,
46 BubbleBorder::horizontal_mirror(BubbleBorder::NONE));
47 EXPECT_EQ(BubbleBorder::FLOAT,
48 BubbleBorder::horizontal_mirror(BubbleBorder::FLOAT));
50 // Vertical mirroring.
51 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT,
52 BubbleBorder::vertical_mirror(BubbleBorder::TOP_LEFT));
53 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT,
54 BubbleBorder::vertical_mirror(BubbleBorder::TOP_RIGHT));
56 EXPECT_EQ(BubbleBorder::TOP_LEFT,
57 BubbleBorder::vertical_mirror(BubbleBorder::BOTTOM_LEFT));
58 EXPECT_EQ(BubbleBorder::TOP_RIGHT,
59 BubbleBorder::vertical_mirror(BubbleBorder::BOTTOM_RIGHT));
61 EXPECT_EQ(BubbleBorder::LEFT_BOTTOM,
62 BubbleBorder::vertical_mirror(BubbleBorder::LEFT_TOP));
63 EXPECT_EQ(BubbleBorder::RIGHT_BOTTOM,
64 BubbleBorder::vertical_mirror(BubbleBorder::RIGHT_TOP));
66 EXPECT_EQ(BubbleBorder::LEFT_TOP,
67 BubbleBorder::vertical_mirror(BubbleBorder::LEFT_BOTTOM));
68 EXPECT_EQ(BubbleBorder::RIGHT_TOP,
69 BubbleBorder::vertical_mirror(BubbleBorder::RIGHT_BOTTOM));
71 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER,
72 BubbleBorder::vertical_mirror(BubbleBorder::TOP_CENTER));
73 EXPECT_EQ(BubbleBorder::TOP_CENTER,
74 BubbleBorder::vertical_mirror(BubbleBorder::BOTTOM_CENTER));
76 EXPECT_EQ(BubbleBorder::LEFT_CENTER,
77 BubbleBorder::vertical_mirror(BubbleBorder::LEFT_CENTER));
78 EXPECT_EQ(BubbleBorder::RIGHT_CENTER,
79 BubbleBorder::vertical_mirror(BubbleBorder::RIGHT_CENTER));
81 EXPECT_EQ(BubbleBorder::NONE,
82 BubbleBorder::vertical_mirror(BubbleBorder::NONE));
83 EXPECT_EQ(BubbleBorder::FLOAT,
84 BubbleBorder::vertical_mirror(BubbleBorder::FLOAT));
87 TEST_F(BubbleBorderTest, HasArrow) {
88 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::TOP_LEFT));
89 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::TOP_RIGHT));
91 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::BOTTOM_LEFT));
92 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::BOTTOM_RIGHT));
94 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::LEFT_TOP));
95 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::RIGHT_TOP));
97 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::LEFT_BOTTOM));
98 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::RIGHT_BOTTOM));
100 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::TOP_CENTER));
101 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::BOTTOM_CENTER));
103 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::LEFT_CENTER));
104 EXPECT_TRUE(BubbleBorder::has_arrow(BubbleBorder::RIGHT_CENTER));
106 EXPECT_FALSE(BubbleBorder::has_arrow(BubbleBorder::NONE));
107 EXPECT_FALSE(BubbleBorder::has_arrow(BubbleBorder::FLOAT));
110 TEST_F(BubbleBorderTest, IsArrowOnLeft) {
111 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::TOP_LEFT));
112 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::TOP_RIGHT));
114 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::BOTTOM_LEFT));
115 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::BOTTOM_RIGHT));
117 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::LEFT_TOP));
118 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::RIGHT_TOP));
120 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::LEFT_BOTTOM));
121 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::RIGHT_BOTTOM));
123 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::TOP_CENTER));
124 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::BOTTOM_CENTER));
126 EXPECT_TRUE(BubbleBorder::is_arrow_on_left(BubbleBorder::LEFT_CENTER));
127 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::RIGHT_CENTER));
129 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::NONE));
130 EXPECT_FALSE(BubbleBorder::is_arrow_on_left(BubbleBorder::FLOAT));
133 TEST_F(BubbleBorderTest, IsArrowOnTop) {
134 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::TOP_LEFT));
135 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::TOP_RIGHT));
137 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::BOTTOM_LEFT));
138 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::BOTTOM_RIGHT));
140 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::LEFT_TOP));
141 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::RIGHT_TOP));
143 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::LEFT_BOTTOM));
144 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::RIGHT_BOTTOM));
146 EXPECT_TRUE(BubbleBorder::is_arrow_on_top(BubbleBorder::TOP_CENTER));
147 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::BOTTOM_CENTER));
149 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::LEFT_CENTER));
150 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::RIGHT_CENTER));
152 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::NONE));
153 EXPECT_FALSE(BubbleBorder::is_arrow_on_top(BubbleBorder::FLOAT));
156 TEST_F(BubbleBorderTest, IsArrowOnHorizontal) {
157 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::TOP_LEFT));
158 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::TOP_RIGHT));
160 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::BOTTOM_LEFT));
161 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::BOTTOM_RIGHT));
163 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::LEFT_TOP));
164 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::RIGHT_TOP));
166 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::LEFT_BOTTOM));
167 EXPECT_FALSE(
168 BubbleBorder::is_arrow_on_horizontal(BubbleBorder::RIGHT_BOTTOM));
170 EXPECT_TRUE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::TOP_CENTER));
171 EXPECT_TRUE(
172 BubbleBorder::is_arrow_on_horizontal(BubbleBorder::BOTTOM_CENTER));
174 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::LEFT_CENTER));
175 EXPECT_FALSE(
176 BubbleBorder::is_arrow_on_horizontal(BubbleBorder::RIGHT_CENTER));
178 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::NONE));
179 EXPECT_FALSE(BubbleBorder::is_arrow_on_horizontal(BubbleBorder::FLOAT));
182 TEST_F(BubbleBorderTest, IsArrowAtCenter) {
183 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::TOP_LEFT));
184 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::TOP_RIGHT));
186 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_LEFT));
187 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_RIGHT));
189 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_TOP));
190 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_TOP));
192 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_BOTTOM));
193 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_BOTTOM));
195 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::TOP_CENTER));
196 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::BOTTOM_CENTER));
198 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::LEFT_CENTER));
199 EXPECT_TRUE(BubbleBorder::is_arrow_at_center(BubbleBorder::RIGHT_CENTER));
201 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::NONE));
202 EXPECT_FALSE(BubbleBorder::is_arrow_at_center(BubbleBorder::FLOAT));
205 TEST_F(BubbleBorderTest, TestMinimalSize) {
206 gfx::Rect anchor = gfx::Rect(100, 100, 20, 20);
207 gfx::Size contents = gfx::Size(10, 10);
208 BubbleBorder b1(BubbleBorder::RIGHT_TOP, BubbleBorder::NO_SHADOW, 0);
210 // The height should be much bigger then the requested size + border and
211 // padding since it needs to be able to include the tip bitmap.
212 gfx::Rect visible_tip_1 = b1.GetBounds(anchor, contents);
213 EXPECT_GE(visible_tip_1.height(), 30);
214 EXPECT_LE(visible_tip_1.width(), 30);
216 // With the tip being invisible the height should now be much smaller.
217 b1.set_paint_arrow(BubbleBorder::PAINT_TRANSPARENT);
218 gfx::Rect invisible_tip_1 = b1.GetBounds(anchor, contents);
219 EXPECT_LE(invisible_tip_1.height(), 30);
220 EXPECT_LE(invisible_tip_1.width(), 30);
222 // When the orientation of the tip changes, the above mentioned tests need to
223 // be reverse for width and height.
224 BubbleBorder b2(BubbleBorder::TOP_RIGHT, BubbleBorder::NO_SHADOW, 0);
226 // The width should be much bigger then the requested size + border and
227 // padding since it needs to be able to include the tip bitmap.
228 gfx::Rect visible_tip_2 = b2.GetBounds(anchor, contents);
229 EXPECT_GE(visible_tip_2.width(), 30);
230 EXPECT_LE(visible_tip_2.height(), 30);
232 // With the tip being invisible the width should now be much smaller.
233 b2.set_paint_arrow(BubbleBorder::PAINT_TRANSPARENT);
234 gfx::Rect invisible_tip_2 = b2.GetBounds(anchor, contents);
235 EXPECT_LE(invisible_tip_2.width(), 30);
236 EXPECT_LE(invisible_tip_2.height(), 30);
240 } // namespace views