OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "ui/base/hit_test.h" | 9 #include "ui/base/hit_test.h" |
10 #include "ui/events/event_processor.h" | 10 #include "ui/events/event_processor.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 { 1000, HTNOWHERE }, | 282 { 1000, HTNOWHERE }, |
283 }; | 283 }; |
284 | 284 |
285 for (size_t i = 0; i < arraysize(cases); ++i) { | 285 for (size_t i = 0; i < arraysize(cases); ++i) { |
286 gfx::Point point(cases[i].point, cases[i].point); | 286 gfx::Point point(cases[i].point, cases[i].point); |
287 EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point)) | 287 EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point)) |
288 << " with border: " << border << ", at point " << cases[i].point; | 288 << " with border: " << border << ", at point " << cases[i].point; |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
| 292 TEST_F(DialogTest, HitTest_CloseButton) { |
| 293 const NonClientView* view = dialog()->GetWidget()->non_client_view(); |
| 294 dialog()->set_show_close_button(true); |
| 295 BubbleFrameView* frame = static_cast<BubbleFrameView*>(view->frame_view()); |
| 296 frame->ResetWindowControls(); |
| 297 |
| 298 const gfx::Rect close_button_bounds = |
| 299 frame->GetCloseButtonForTest()->bounds(); |
| 300 EXPECT_EQ(HTCLOSE, |
| 301 frame->NonClientHitTest(gfx::Point(close_button_bounds.x() + 4, |
| 302 close_button_bounds.y() + 4))); |
| 303 } |
| 304 |
292 TEST_F(DialogTest, BoundsAccommodateTitle) { | 305 TEST_F(DialogTest, BoundsAccommodateTitle) { |
293 TestDialog* dialog2(new TestDialog()); | 306 TestDialog* dialog2(new TestDialog()); |
294 dialog2->set_title(base::ASCIIToUTF16("Title")); | 307 dialog2->set_title(base::ASCIIToUTF16("Title")); |
295 DialogDelegate::CreateDialogWidget(dialog2, GetContext(), nullptr); | 308 DialogDelegate::CreateDialogWidget(dialog2, GetContext(), nullptr); |
296 | 309 |
297 // Titled dialogs have taller initial frame bounds than untitled dialogs. | 310 // Titled dialogs have taller initial frame bounds than untitled dialogs. |
298 View* frame1 = dialog()->GetWidget()->non_client_view()->frame_view(); | 311 View* frame1 = dialog()->GetWidget()->non_client_view()->frame_view(); |
299 View* frame2 = dialog2->GetWidget()->non_client_view()->frame_view(); | 312 View* frame2 = dialog2->GetWidget()->non_client_view()->frame_view(); |
300 EXPECT_LT(frame1->GetPreferredSize().height(), | 313 EXPECT_LT(frame1->GetPreferredSize().height(), |
301 frame2->GetPreferredSize().height()); | 314 frame2->GetPreferredSize().height()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 } | 401 } |
389 | 402 |
390 TEST_F(DialogTest, DontSnapWithoutButtons) { | 403 TEST_F(DialogTest, DontSnapWithoutButtons) { |
391 TestDialog dialog; | 404 TestDialog dialog; |
392 EXPECT_TRUE(dialog.ShouldSnapFrameWidth()); | 405 EXPECT_TRUE(dialog.ShouldSnapFrameWidth()); |
393 dialog.set_dialog_buttons(ui::DIALOG_BUTTON_NONE); | 406 dialog.set_dialog_buttons(ui::DIALOG_BUTTON_NONE); |
394 EXPECT_FALSE(dialog.ShouldSnapFrameWidth()); | 407 EXPECT_FALSE(dialog.ShouldSnapFrameWidth()); |
395 } | 408 } |
396 | 409 |
397 } // namespace views | 410 } // namespace views |
OLD | NEW |