| 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/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 |
| 23 namespace { | |
| 24 | |
| 25 class SizedBubbleDelegateView : public BubbleDelegateView { | 25 class SizedBubbleDelegateView : public BubbleDelegateView { |
| 26 public: | 26 public: |
| 27 SizedBubbleDelegateView(); | 27 SizedBubbleDelegateView(); |
| 28 virtual ~SizedBubbleDelegateView(); | 28 virtual ~SizedBubbleDelegateView(); |
| 29 | 29 |
| 30 // View overrides: | 30 // View overrides: |
| 31 virtual gfx::Size GetPreferredSize() OVERRIDE; | 31 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(SizedBubbleDelegateView); | 34 DISALLOW_COPY_AND_ASSIGN(SizedBubbleDelegateView); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 gfx::Insets insets; | 108 gfx::Insets insets; |
| 109 frame.bubble_border()->GetInsets(&insets); | 109 frame.bubble_border()->GetInsets(&insets); |
| 110 int xposition = 95 - insets.width(); | 110 int xposition = 95 - insets.width(); |
| 111 | 111 |
| 112 // Test that the info bubble displays normally when it fits. | 112 // Test that the info bubble displays normally when it fits. |
| 113 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); | 113 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); |
| 114 window_bounds = frame.GetUpdatedWindowBounds( | 114 window_bounds = frame.GetUpdatedWindowBounds( |
| 115 gfx::Rect(100, 100, 50, 50), // |anchor_rect| | 115 gfx::Rect(100, 100, 50, 50), // |anchor_rect| |
| 116 gfx::Size(500, 500), // |client_size| | 116 gfx::Size(500, 500), // |client_size| |
| 117 true); // |try_mirroring_arrow| | 117 true); // |adjust_if_offscreen| |
| 118 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); | 118 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); |
| 119 EXPECT_GT(window_bounds.x(), xposition); | 119 EXPECT_GT(window_bounds.x(), xposition); |
| 120 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for | 120 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for |
| 121 // arrow overlap. | 121 // arrow overlap. |
| 122 | 122 |
| 123 // Test bubble not fitting on left. | 123 // Test bubble not fitting on left. |
| 124 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); | 124 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); |
| 125 window_bounds = frame.GetUpdatedWindowBounds( | 125 window_bounds = frame.GetUpdatedWindowBounds( |
| 126 gfx::Rect(100, 100, 50, 50), // |anchor_rect| | 126 gfx::Rect(100, 100, 50, 50), // |anchor_rect| |
| 127 gfx::Size(500, 500), // |client_size| | 127 gfx::Size(500, 500), // |client_size| |
| 128 true); // |try_mirroring_arrow| | 128 true); // |adjust_if_offscreen| |
| 129 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); | 129 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); |
| 130 EXPECT_GT(window_bounds.x(), xposition); | 130 EXPECT_GT(window_bounds.x(), xposition); |
| 131 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for | 131 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for |
| 132 // arrow overlap. | 132 // arrow overlap. |
| 133 | 133 |
| 134 // Test bubble not fitting on left or top. | 134 // Test bubble not fitting on left or top. |
| 135 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_RIGHT); | 135 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_RIGHT); |
| 136 window_bounds = frame.GetUpdatedWindowBounds( | 136 window_bounds = frame.GetUpdatedWindowBounds( |
| 137 gfx::Rect(100, 100, 50, 50), // |anchor_rect| | 137 gfx::Rect(100, 100, 50, 50), // |anchor_rect| |
| 138 gfx::Size(500, 500), // |client_size| | 138 gfx::Size(500, 500), // |client_size| |
| 139 true); // |try_mirroring_arrow| | 139 true); // |adjust_if_offscreen| |
| 140 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); | 140 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); |
| 141 EXPECT_GT(window_bounds.x(), xposition); | 141 EXPECT_GT(window_bounds.x(), xposition); |
| 142 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for | 142 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for |
| 143 // arrow overlap. | 143 // arrow overlap. |
| 144 | 144 |
| 145 // Test bubble not fitting on top. | 145 // Test bubble not fitting on top. |
| 146 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_LEFT); | 146 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_LEFT); |
| 147 window_bounds = frame.GetUpdatedWindowBounds( | 147 window_bounds = frame.GetUpdatedWindowBounds( |
| 148 gfx::Rect(100, 100, 50, 50), // |anchor_rect| | 148 gfx::Rect(100, 100, 50, 50), // |anchor_rect| |
| 149 gfx::Size(500, 500), // |client_size| | 149 gfx::Size(500, 500), // |client_size| |
| 150 true); // |try_mirroring_arrow| | 150 true); // |adjust_if_offscreen| |
| 151 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); | 151 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); |
| 152 EXPECT_GT(window_bounds.x(), xposition); | 152 EXPECT_GT(window_bounds.x(), xposition); |
| 153 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for | 153 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for |
| 154 // arrow overlap. | 154 // arrow overlap. |
| 155 | 155 |
| 156 // Test bubble not fitting on top and right. | 156 // Test bubble not fitting on top and right. |
| 157 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_LEFT); | 157 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_LEFT); |
| 158 window_bounds = frame.GetUpdatedWindowBounds( | 158 window_bounds = frame.GetUpdatedWindowBounds( |
| 159 gfx::Rect(900, 100, 50, 50), // |anchor_rect| | 159 gfx::Rect(900, 100, 50, 50), // |anchor_rect| |
| 160 gfx::Size(500, 500), // |client_size| | 160 gfx::Size(500, 500), // |client_size| |
| 161 true); // |try_mirroring_arrow| | 161 true); // |adjust_if_offscreen| |
| 162 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); | 162 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); |
| 163 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); | 163 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); |
| 164 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for | 164 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for |
| 165 // arrow overlap. | 165 // arrow overlap. |
| 166 | 166 |
| 167 // Test bubble not fitting on right. | 167 // Test bubble not fitting on right. |
| 168 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); | 168 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); |
| 169 window_bounds = frame.GetUpdatedWindowBounds( | 169 window_bounds = frame.GetUpdatedWindowBounds( |
| 170 gfx::Rect(900, 100, 50, 50), // |anchor_rect| | 170 gfx::Rect(900, 100, 50, 50), // |anchor_rect| |
| 171 gfx::Size(500, 500), // |client_size| | 171 gfx::Size(500, 500), // |client_size| |
| 172 true); // |try_mirroring_arrow| | 172 true); // |adjust_if_offscreen| |
| 173 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); | 173 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); |
| 174 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); | 174 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); |
| 175 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for | 175 EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for |
| 176 // arrow overlap. | 176 // arrow overlap. |
| 177 | 177 |
| 178 // Test bubble not fitting on bottom and right. | 178 // Test bubble not fitting on bottom and right. |
| 179 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); | 179 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); |
| 180 window_bounds = frame.GetUpdatedWindowBounds( | 180 window_bounds = frame.GetUpdatedWindowBounds( |
| 181 gfx::Rect(900, 900, 50, 50), // |anchor_rect| | 181 gfx::Rect(900, 900, 50, 50), // |anchor_rect| |
| 182 gfx::Size(500, 500), // |client_size| | 182 gfx::Size(500, 500), // |client_size| |
| 183 true); // |try_mirroring_arrow| | 183 true); // |adjust_if_offscreen| |
| 184 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT, | 184 EXPECT_EQ(BubbleBorder::BOTTOM_RIGHT, |
| 185 frame.bubble_border()->arrow_location()); | 185 frame.bubble_border()->arrow_location()); |
| 186 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); | 186 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); |
| 187 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate | 187 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate |
| 188 // for arrow height. | 188 // for arrow height. |
| 189 | 189 |
| 190 // Test bubble not fitting at the bottom. | 190 // Test bubble not fitting at the bottom. |
| 191 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); | 191 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); |
| 192 window_bounds = frame.GetUpdatedWindowBounds( | 192 window_bounds = frame.GetUpdatedWindowBounds( |
| 193 gfx::Rect(100, 900, 50, 50), // |anchor_rect| | 193 gfx::Rect(100, 900, 50, 50), // |anchor_rect| |
| 194 gfx::Size(500, 500), // |client_size| | 194 gfx::Size(500, 500), // |client_size| |
| 195 true); // |try_mirroring_arrow| | 195 true); // |adjust_if_offscreen| |
| 196 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT, frame.bubble_border()->arrow_location()); | 196 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT, frame.bubble_border()->arrow_location()); |
| 197 // The window should be right aligned with the anchor_rect. | 197 // The window should be right aligned with the anchor_rect. |
| 198 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); | 198 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); |
| 199 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate | 199 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate |
| 200 // for arrow height. | 200 // for arrow height. |
| 201 | 201 |
| 202 // Test bubble not fitting at the bottom and left. | 202 // Test bubble not fitting at the bottom and left. |
| 203 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); | 203 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); |
| 204 window_bounds = frame.GetUpdatedWindowBounds( | 204 window_bounds = frame.GetUpdatedWindowBounds( |
| 205 gfx::Rect(100, 900, 50, 50), // |anchor_rect| | 205 gfx::Rect(100, 900, 50, 50), // |anchor_rect| |
| 206 gfx::Size(500, 500), // |client_size| | 206 gfx::Size(500, 500), // |client_size| |
| 207 true); // |try_mirroring_arrow| | 207 true); // |adjust_if_offscreen| |
| 208 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT, frame.bubble_border()->arrow_location()); | 208 EXPECT_EQ(BubbleBorder::BOTTOM_LEFT, frame.bubble_border()->arrow_location()); |
| 209 // The window should be right aligned with the anchor_rect. | 209 // The window should be right aligned with the anchor_rect. |
| 210 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); | 210 EXPECT_LT(window_bounds.x(), 900 + 50 - 500); |
| 211 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate | 211 EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate |
| 212 // for arrow height. | 212 // for arrow height. |
| 213 } | 213 } |
| 214 | 214 |
| 215 // Tests that the arrow is not moved when the info-bubble does not fit the | 215 // Tests that the arrow is not moved when the info-bubble does not fit the |
| 216 // screen but moving it would make matter worse. | 216 // screen but moving it would make matter worse. |
| 217 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsMirroringFails) { | 217 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsMirroringFails) { |
| 218 TestBubbleFrameView frame; | 218 TestBubbleFrameView frame; |
| 219 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); | 219 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); |
| 220 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( | 220 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( |
| 221 gfx::Rect(400, 100, 50, 50), // |anchor_rect| | 221 gfx::Rect(400, 100, 50, 50), // |anchor_rect| |
| 222 gfx::Size(500, 700), // |client_size| | 222 gfx::Size(500, 700), // |client_size| |
| 223 true); // |try_mirroring_arrow| | 223 true); // |adjust_if_offscreen| |
| 224 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); | 224 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); |
| 225 } | 225 } |
| 226 | 226 |
| 227 // Test that the arrow will not be mirrored when |try_mirroring_arrow| is false. | 227 // Test that the arrow will not be mirrored when |adjust_if_offscreen| is false. |
| 228 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsDontTryMirror) { | 228 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsDontTryMirror) { |
| 229 TestBubbleFrameView frame; | 229 TestBubbleFrameView frame; |
| 230 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); | 230 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); |
| 231 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( | 231 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( |
| 232 gfx::Rect(100, 900, 50, 50), // |anchor_rect| | 232 gfx::Rect(100, 900, 50, 50), // |anchor_rect| |
| 233 gfx::Size(500, 500), // |client_size| | 233 gfx::Size(500, 500), // |client_size| |
| 234 false); // |try_mirroring_arrow| | 234 false); // |adjust_if_offscreen| |
| 235 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); | 235 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); |
| 236 // The coordinates should be pointing to anchor_rect from TOP_RIGHT. | 236 // The coordinates should be pointing to anchor_rect from TOP_RIGHT. |
| 237 EXPECT_LT(window_bounds.x(), 100 + 50 - 500); | 237 EXPECT_LT(window_bounds.x(), 100 + 50 - 500); |
| 238 EXPECT_GT(window_bounds.y(), 900 + 50 - 10); // -10 to roughly compensate for | 238 EXPECT_GT(window_bounds.y(), 900 + 50 - 10); // -10 to roughly compensate for |
| 239 // arrow overlap. | 239 // arrow overlap. |
| 240 } | 240 } |
| 241 | 241 |
| 242 // Test that the center arrow is moved as needed to fit the screen. |
| 243 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsCenterArrows) { |
| 244 TestBubbleFrameView frame; |
| 245 gfx::Rect window_bounds; |
| 246 |
| 247 // Test that the bubble displays normally when it fits. |
| 248 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_CENTER); |
| 249 window_bounds = frame.GetUpdatedWindowBounds( |
| 250 gfx::Rect(500, 100, 50, 50), // |anchor_rect| |
| 251 gfx::Size(500, 500), // |client_size| |
| 252 true); // |adjust_if_offscreen| |
| 253 EXPECT_EQ(BubbleBorder::TOP_CENTER, frame.bubble_border()->arrow_location()); |
| 254 EXPECT_EQ(window_bounds.x() + window_bounds.width() / 2, 525); |
| 255 |
| 256 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_CENTER); |
| 257 window_bounds = frame.GetUpdatedWindowBounds( |
| 258 gfx::Rect(500, 900, 50, 50), // |anchor_rect| |
| 259 gfx::Size(500, 500), // |client_size| |
| 260 true); // |adjust_if_offscreen| |
| 261 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER, |
| 262 frame.bubble_border()->arrow_location()); |
| 263 EXPECT_EQ(window_bounds.x() + window_bounds.width() / 2, 525); |
| 264 |
| 265 frame.bubble_border()->set_arrow_location(BubbleBorder::LEFT_CENTER); |
| 266 window_bounds = frame.GetUpdatedWindowBounds( |
| 267 gfx::Rect(100, 400, 50, 50), // |anchor_rect| |
| 268 gfx::Size(500, 500), // |client_size| |
| 269 true); // |adjust_if_offscreen| |
| 270 EXPECT_EQ(BubbleBorder::LEFT_CENTER, frame.bubble_border()->arrow_location()); |
| 271 EXPECT_EQ(window_bounds.y() + window_bounds.height() / 2, 425); |
| 272 |
| 273 frame.bubble_border()->set_arrow_location(BubbleBorder::RIGHT_CENTER); |
| 274 window_bounds = frame.GetUpdatedWindowBounds( |
| 275 gfx::Rect(900, 400, 50, 50), // |anchor_rect| |
| 276 gfx::Size(500, 500), // |client_size| |
| 277 true); // |adjust_if_offscreen| |
| 278 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, |
| 279 frame.bubble_border()->arrow_location()); |
| 280 EXPECT_EQ(window_bounds.y() + window_bounds.height() / 2, 425); |
| 281 |
| 282 // Test bubble not fitting left screen edge. |
| 283 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_CENTER); |
| 284 window_bounds = frame.GetUpdatedWindowBounds( |
| 285 gfx::Rect(100, 100, 50, 50), // |anchor_rect| |
| 286 gfx::Size(500, 500), // |client_size| |
| 287 true); // |adjust_if_offscreen| |
| 288 EXPECT_EQ(BubbleBorder::TOP_CENTER, frame.bubble_border()->arrow_location()); |
| 289 EXPECT_EQ(window_bounds.x(), 0); |
| 290 EXPECT_EQ(window_bounds.x() + |
| 291 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 125); |
| 292 |
| 293 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_CENTER); |
| 294 window_bounds = frame.GetUpdatedWindowBounds( |
| 295 gfx::Rect(100, 900, 50, 50), // |anchor_rect| |
| 296 gfx::Size(500, 500), // |client_size| |
| 297 true); // |adjust_if_offscreen| |
| 298 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER, |
| 299 frame.bubble_border()->arrow_location()); |
| 300 EXPECT_EQ(window_bounds.x(), 0); |
| 301 EXPECT_EQ(window_bounds.x() + |
| 302 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 125); |
| 303 |
| 304 // Test bubble not fitting right screen edge. |
| 305 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_CENTER); |
| 306 window_bounds = frame.GetUpdatedWindowBounds( |
| 307 gfx::Rect(900, 100, 50, 50), // |anchor_rect| |
| 308 gfx::Size(500, 500), // |client_size| |
| 309 true); // |adjust_if_offscreen| |
| 310 EXPECT_EQ(BubbleBorder::TOP_CENTER, frame.bubble_border()->arrow_location()); |
| 311 EXPECT_EQ(window_bounds.right(), 1000); |
| 312 EXPECT_EQ(window_bounds.x() + |
| 313 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); |
| 314 |
| 315 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_CENTER); |
| 316 window_bounds = frame.GetUpdatedWindowBounds( |
| 317 gfx::Rect(900, 900, 50, 50), // |anchor_rect| |
| 318 gfx::Size(500, 500), // |client_size| |
| 319 true); // |adjust_if_offscreen| |
| 320 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER, |
| 321 frame.bubble_border()->arrow_location()); |
| 322 EXPECT_EQ(window_bounds.right(), 1000); |
| 323 EXPECT_EQ(window_bounds.x() + |
| 324 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); |
| 325 |
| 326 // Test bubble not fitting top screen edge. |
| 327 frame.bubble_border()->set_arrow_location(BubbleBorder::LEFT_CENTER); |
| 328 window_bounds = frame.GetUpdatedWindowBounds( |
| 329 gfx::Rect(100, 100, 50, 50), // |anchor_rect| |
| 330 gfx::Size(500, 500), // |client_size| |
| 331 true); // |adjust_if_offscreen| |
| 332 EXPECT_EQ(BubbleBorder::LEFT_CENTER, frame.bubble_border()->arrow_location()); |
| 333 EXPECT_EQ(window_bounds.y(), 0); |
| 334 EXPECT_EQ(window_bounds.y() + |
| 335 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 125); |
| 336 |
| 337 frame.bubble_border()->set_arrow_location(BubbleBorder::RIGHT_CENTER); |
| 338 window_bounds = frame.GetUpdatedWindowBounds( |
| 339 gfx::Rect(900, 100, 50, 50), // |anchor_rect| |
| 340 gfx::Size(500, 500), // |client_size| |
| 341 true); // |adjust_if_offscreen| |
| 342 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, |
| 343 frame.bubble_border()->arrow_location()); |
| 344 EXPECT_EQ(window_bounds.y(), 0); |
| 345 EXPECT_EQ(window_bounds.y() + |
| 346 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 125); |
| 347 |
| 348 // Test bubble not fitting bottom screen edge. |
| 349 frame.bubble_border()->set_arrow_location(BubbleBorder::LEFT_CENTER); |
| 350 window_bounds = frame.GetUpdatedWindowBounds( |
| 351 gfx::Rect(100, 900, 50, 50), // |anchor_rect| |
| 352 gfx::Size(500, 500), // |client_size| |
| 353 true); // |adjust_if_offscreen| |
| 354 EXPECT_EQ(BubbleBorder::LEFT_CENTER, frame.bubble_border()->arrow_location()); |
| 355 EXPECT_EQ(window_bounds.bottom(), 1000); |
| 356 EXPECT_EQ(window_bounds.y() + |
| 357 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); |
| 358 |
| 359 frame.bubble_border()->set_arrow_location(BubbleBorder::RIGHT_CENTER); |
| 360 window_bounds = frame.GetUpdatedWindowBounds( |
| 361 gfx::Rect(900, 900, 50, 50), // |anchor_rect| |
| 362 gfx::Size(500, 500), // |client_size| |
| 363 true); // |adjust_if_offscreen| |
| 364 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, |
| 365 frame.bubble_border()->arrow_location()); |
| 366 EXPECT_EQ(window_bounds.bottom(), 1000); |
| 367 EXPECT_EQ(window_bounds.y() + |
| 368 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); |
| 369 } |
| 370 |
| 242 } // namespace views | 371 } // namespace views |
| OLD | NEW |