Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: ui/views/window/dialog_delegate_unittest.cc

Issue 2861533003: Backfill some UI tests. (Closed)
Patch Set: minor edits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
287 TEST_F(DialogTest, BoundsAccommodateTitle) { 300 TEST_F(DialogTest, BoundsAccommodateTitle) {
288 TestDialog* dialog2(new TestDialog()); 301 TestDialog* dialog2(new TestDialog());
289 dialog2->set_title(base::ASCIIToUTF16("Title")); 302 dialog2->set_title(base::ASCIIToUTF16("Title"));
290 DialogDelegate::CreateDialogWidget(dialog2, GetContext(), nullptr); 303 DialogDelegate::CreateDialogWidget(dialog2, GetContext(), nullptr);
291 304
292 // Titled dialogs have taller initial frame bounds than untitled dialogs. 305 // Titled dialogs have taller initial frame bounds than untitled dialogs.
293 View* frame1 = dialog()->GetWidget()->non_client_view()->frame_view(); 306 View* frame1 = dialog()->GetWidget()->non_client_view()->frame_view();
294 View* frame2 = dialog2->GetWidget()->non_client_view()->frame_view(); 307 View* frame2 = dialog2->GetWidget()->non_client_view()->frame_view();
295 EXPECT_LT(frame1->GetPreferredSize().height(), 308 EXPECT_LT(frame1->GetPreferredSize().height(),
296 frame2->GetPreferredSize().height()); 309 frame2->GetPreferredSize().height());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 // On showing the dialog, the initially focused View will be the OK button. 389 // On showing the dialog, the initially focused View will be the OK button.
377 // Since it is no longer focusable, focus should advance to the next focusable 390 // Since it is no longer focusable, focus should advance to the next focusable
378 // View, which is |textfield|. 391 // View, which is |textfield|.
379 dialog_widget->Show(); 392 dialog_widget->Show();
380 EXPECT_TRUE(textfield->HasFocus()); 393 EXPECT_TRUE(textfield->HasFocus());
381 EXPECT_EQ(textfield, dialog->GetFocusManager()->GetFocusedView()); 394 EXPECT_EQ(textfield, dialog->GetFocusManager()->GetFocusedView());
382 dialog_widget->CloseNow(); 395 dialog_widget->CloseNow();
383 } 396 }
384 397
385 } // namespace views 398 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698