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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 { 1000, HTNOWHERE }, | 277 { 1000, HTNOWHERE }, |
278 }; | 278 }; |
279 | 279 |
280 for (size_t i = 0; i < arraysize(cases); ++i) { | 280 for (size_t i = 0; i < arraysize(cases); ++i) { |
281 gfx::Point point(cases[i].point, cases[i].point); | 281 gfx::Point point(cases[i].point, cases[i].point); |
282 EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point)) | 282 EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point)) |
283 << " with border: " << border << ", at point " << cases[i].point; | 283 << " with border: " << border << ", at point " << cases[i].point; |
284 } | 284 } |
285 } | 285 } |
286 | 286 |
287 TEST_F(DialogTest, HitTest_CloseButton) { | |
288 const NonClientView* view = dialog()->GetWidget()->non_client_view(); | |
289 dialog()->set_show_close_button(true); | |
290 BubbleFrameView* frame = static_cast<BubbleFrameView*>(view->frame_view()); | |
291 frame->ResetWindowControls(); | |
292 | |
293 const gfx::Rect close_button_bounds = | |
294 frame->GetCloseButtonForTest()->bounds(); | |
295 EXPECT_EQ(HTCLOSE, | |
296 frame->NonClientHitTest(gfx::Point(close_button_bounds.x() + 4, | |
297 close_button_bounds.y() + 4))); | |
298 } | |
299 | |
300 TEST_F(DialogTest, BoundsAccommodateTitle) { | 287 TEST_F(DialogTest, BoundsAccommodateTitle) { |
301 TestDialog* dialog2(new TestDialog()); | 288 TestDialog* dialog2(new TestDialog()); |
302 dialog2->set_title(base::ASCIIToUTF16("Title")); | 289 dialog2->set_title(base::ASCIIToUTF16("Title")); |
303 DialogDelegate::CreateDialogWidget(dialog2, GetContext(), nullptr); | 290 DialogDelegate::CreateDialogWidget(dialog2, GetContext(), nullptr); |
304 | 291 |
305 // Titled dialogs have taller initial frame bounds than untitled dialogs. | 292 // Titled dialogs have taller initial frame bounds than untitled dialogs. |
306 View* frame1 = dialog()->GetWidget()->non_client_view()->frame_view(); | 293 View* frame1 = dialog()->GetWidget()->non_client_view()->frame_view(); |
307 View* frame2 = dialog2->GetWidget()->non_client_view()->frame_view(); | 294 View* frame2 = dialog2->GetWidget()->non_client_view()->frame_view(); |
308 EXPECT_LT(frame1->GetPreferredSize().height(), | 295 EXPECT_LT(frame1->GetPreferredSize().height(), |
309 frame2->GetPreferredSize().height()); | 296 frame2->GetPreferredSize().height()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 // On showing the dialog, the initially focused View will be the OK button. | 376 // On showing the dialog, the initially focused View will be the OK button. |
390 // Since it is no longer focusable, focus should advance to the next focusable | 377 // Since it is no longer focusable, focus should advance to the next focusable |
391 // View, which is |textfield|. | 378 // View, which is |textfield|. |
392 dialog_widget->Show(); | 379 dialog_widget->Show(); |
393 EXPECT_TRUE(textfield->HasFocus()); | 380 EXPECT_TRUE(textfield->HasFocus()); |
394 EXPECT_EQ(textfield, dialog->GetFocusManager()->GetFocusedView()); | 381 EXPECT_EQ(textfield, dialog->GetFocusManager()->GetFocusedView()); |
395 dialog_widget->CloseNow(); | 382 dialog_widget->CloseNow(); |
396 } | 383 } |
397 | 384 |
398 } // namespace views | 385 } // namespace views |
OLD | NEW |