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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 317 |
318 // Giving the default test dialog a title will yield the same bounds. | 318 // Giving the default test dialog a title will yield the same bounds. |
319 dialog()->set_title(base::ASCIIToUTF16("Title")); | 319 dialog()->set_title(base::ASCIIToUTF16("Title")); |
320 dialog()->GetWidget()->UpdateWindowTitle(); | 320 dialog()->GetWidget()->UpdateWindowTitle(); |
321 EXPECT_EQ(frame1->GetPreferredSize().height(), | 321 EXPECT_EQ(frame1->GetPreferredSize().height(), |
322 frame2->GetPreferredSize().height()); | 322 frame2->GetPreferredSize().height()); |
323 | 323 |
324 dialog2->TearDown(); | 324 dialog2->TearDown(); |
325 } | 325 } |
326 | 326 |
| 327 TEST_F(DialogTest, ActualBoundsMatchPreferredBounds) { |
| 328 dialog()->set_title(base::ASCIIToUTF16( |
| 329 "La la la look at me I'm a really really long title that needs to be " |
| 330 "really really long so that the title will multiline wrap.")); |
| 331 dialog()->GetWidget()->UpdateWindowTitle(); |
| 332 |
| 333 views::View* root_view = dialog()->GetWidget()->GetRootView(); |
| 334 gfx::Size preferred_size(root_view->GetPreferredSize()); |
| 335 EXPECT_FALSE(preferred_size.IsEmpty()); |
| 336 root_view->SizeToPreferredSize(); |
| 337 root_view->Layout(); |
| 338 EXPECT_EQ(preferred_size, root_view->size()); |
| 339 } |
| 340 |
327 // Tests default focus is assigned correctly when showing a new dialog. | 341 // Tests default focus is assigned correctly when showing a new dialog. |
328 TEST_F(DialogTest, InitialFocus) { | 342 TEST_F(DialogTest, InitialFocus) { |
329 EXPECT_TRUE(dialog()->input()->HasFocus()); | 343 EXPECT_TRUE(dialog()->input()->HasFocus()); |
330 EXPECT_EQ(dialog()->input(), dialog()->GetFocusManager()->GetFocusedView()); | 344 EXPECT_EQ(dialog()->input(), dialog()->GetFocusManager()->GetFocusedView()); |
331 } | 345 } |
332 | 346 |
333 // A dialog for testing initial focus with only an OK button. | 347 // A dialog for testing initial focus with only an OK button. |
334 class InitialFocusTestDialog : public DialogDelegateView { | 348 class InitialFocusTestDialog : public DialogDelegateView { |
335 public: | 349 public: |
336 InitialFocusTestDialog() {} | 350 InitialFocusTestDialog() {} |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 417 } |
404 | 418 |
405 TEST_F(DialogTest, DontSnapWithoutButtons) { | 419 TEST_F(DialogTest, DontSnapWithoutButtons) { |
406 TestDialog dialog; | 420 TestDialog dialog; |
407 EXPECT_TRUE(dialog.ShouldSnapFrameWidth()); | 421 EXPECT_TRUE(dialog.ShouldSnapFrameWidth()); |
408 dialog.set_dialog_buttons(ui::DIALOG_BUTTON_NONE); | 422 dialog.set_dialog_buttons(ui::DIALOG_BUTTON_NONE); |
409 EXPECT_FALSE(dialog.ShouldSnapFrameWidth()); | 423 EXPECT_FALSE(dialog.ShouldSnapFrameWidth()); |
410 } | 424 } |
411 | 425 |
412 } // namespace views | 426 } // namespace views |
OLD | NEW |