| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ui/base/ui_base_types.h" | 8 #include "ui/base/ui_base_types.h" |
| 9 #include "ui/views/controls/button/label_button.h" | 9 #include "ui/views/controls/button/label_button.h" |
| 10 #include "ui/views/style/platform_style.h" |
| 10 #include "ui/views/test/test_views.h" | 11 #include "ui/views/test/test_views.h" |
| 11 #include "ui/views/test/views_test_base.h" | 12 #include "ui/views/test/views_test_base.h" |
| 12 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 13 #include "ui/views/window/dialog_client_view.h" | 14 #include "ui/views/window/dialog_client_view.h" |
| 14 #include "ui/views/window/dialog_delegate.h" | 15 #include "ui/views/window/dialog_delegate.h" |
| 15 | 16 |
| 16 namespace views { | 17 namespace views { |
| 17 | 18 |
| 18 class TestDialogClientView : public DialogClientView { | 19 class TestDialogClientView : public DialogClientView { |
| 19 public: | 20 public: |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 142 |
| 142 // Reset with just an ok button. | 143 // Reset with just an ok button. |
| 143 SetDialogButtons(ui::DIALOG_BUTTON_OK); | 144 SetDialogButtons(ui::DIALOG_BUTTON_OK); |
| 144 EXPECT_TRUE(client_view()->ok_button()->is_default()); | 145 EXPECT_TRUE(client_view()->ok_button()->is_default()); |
| 145 EXPECT_EQ(NULL, client_view()->cancel_button()); | 146 EXPECT_EQ(NULL, client_view()->cancel_button()); |
| 146 EXPECT_EQ(GetUpdatedClientBounds().height(), height_with_buttons); | 147 EXPECT_EQ(GetUpdatedClientBounds().height(), height_with_buttons); |
| 147 | 148 |
| 148 // Reset with just a cancel button. | 149 // Reset with just a cancel button. |
| 149 SetDialogButtons(ui::DIALOG_BUTTON_CANCEL); | 150 SetDialogButtons(ui::DIALOG_BUTTON_CANCEL); |
| 150 EXPECT_EQ(NULL, client_view()->ok_button()); | 151 EXPECT_EQ(NULL, client_view()->ok_button()); |
| 151 EXPECT_TRUE(client_view()->cancel_button()->is_default()); | 152 EXPECT_EQ(client_view()->cancel_button()->is_default(), |
| 153 PlatformStyle::kDialogDefaultButtonCanBeCancel); |
| 152 EXPECT_EQ(GetUpdatedClientBounds().height(), height_with_buttons); | 154 EXPECT_EQ(GetUpdatedClientBounds().height(), height_with_buttons); |
| 153 } | 155 } |
| 154 | 156 |
| 155 TEST_F(DialogClientViewTest, RemoveAndUpdateButtons) { | 157 TEST_F(DialogClientViewTest, RemoveAndUpdateButtons) { |
| 156 // Removing buttons from another context should clear the local pointer. | 158 // Removing buttons from another context should clear the local pointer. |
| 157 SetDialogButtons(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL); | 159 SetDialogButtons(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL); |
| 158 delete client_view()->ok_button(); | 160 delete client_view()->ok_button(); |
| 159 EXPECT_EQ(NULL, client_view()->ok_button()); | 161 EXPECT_EQ(NULL, client_view()->ok_button()); |
| 160 delete client_view()->cancel_button(); | 162 delete client_view()->cancel_button(); |
| 161 EXPECT_EQ(NULL, client_view()->cancel_button()); | 163 EXPECT_EQ(NULL, client_view()->cancel_button()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 EXPECT_EQ(no_extra_view_size.width(), client_view()->bounds().width()); | 247 EXPECT_EQ(no_extra_view_size.width(), client_view()->bounds().width()); |
| 246 | 248 |
| 247 // Try with a reduced-size dialog. | 249 // Try with a reduced-size dialog. |
| 248 extra_view->SetVisible(true); | 250 extra_view->SetVisible(true); |
| 249 client_view()->SetBoundsRect(gfx::Rect(gfx::Point(0, 0), no_extra_view_size)); | 251 client_view()->SetBoundsRect(gfx::Rect(gfx::Point(0, 0), no_extra_view_size)); |
| 250 client_view()->Layout(); | 252 client_view()->Layout(); |
| 251 EXPECT_GT(width_of_extra_view, extra_view->bounds().width()); | 253 EXPECT_GT(width_of_extra_view, extra_view->bounds().width()); |
| 252 } | 254 } |
| 253 | 255 |
| 254 } // namespace views | 256 } // namespace views |
| OLD | NEW |