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/test/test_views.h" | 10 #include "ui/views/test/test_views.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void SetExtraViewPadding(int padding) { | 103 void SetExtraViewPadding(int padding) { |
104 DCHECK(!extra_view_padding_); | 104 DCHECK(!extra_view_padding_); |
105 extra_view_padding_.reset(new int(padding)); | 105 extra_view_padding_.reset(new int(padding)); |
106 client_view_->Layout(); | 106 client_view_->Layout(); |
107 } | 107 } |
108 | 108 |
109 TestDialogClientView* client_view() { return client_view_.get(); } | 109 TestDialogClientView* client_view() { return client_view_.get(); } |
110 | 110 |
111 private: | 111 private: |
112 // The DialogClientView that's being tested. | 112 // The DialogClientView that's being tested. |
113 scoped_ptr<TestDialogClientView> client_view_; | 113 std::unique_ptr<TestDialogClientView> client_view_; |
114 // The bitmask of buttons to show in the dialog. | 114 // The bitmask of buttons to show in the dialog. |
115 int dialog_buttons_; | 115 int dialog_buttons_; |
116 View* extra_view_; // weak | 116 View* extra_view_; // weak |
117 scoped_ptr<int> extra_view_padding_; // Null by default. | 117 std::unique_ptr<int> extra_view_padding_; // Null by default. |
118 | 118 |
119 DISALLOW_COPY_AND_ASSIGN(DialogClientViewTest); | 119 DISALLOW_COPY_AND_ASSIGN(DialogClientViewTest); |
120 }; | 120 }; |
121 | 121 |
122 TEST_F(DialogClientViewTest, UpdateButtons) { | 122 TEST_F(DialogClientViewTest, UpdateButtons) { |
123 // This dialog should start with no buttons. | 123 // This dialog should start with no buttons. |
124 EXPECT_EQ(GetDialogButtons(), ui::DIALOG_BUTTON_NONE); | 124 EXPECT_EQ(GetDialogButtons(), ui::DIALOG_BUTTON_NONE); |
125 EXPECT_EQ(NULL, client_view()->ok_button()); | 125 EXPECT_EQ(NULL, client_view()->ok_button()); |
126 EXPECT_EQ(NULL, client_view()->cancel_button()); | 126 EXPECT_EQ(NULL, client_view()->cancel_button()); |
127 const int height_without_buttons = GetUpdatedClientBounds().height(); | 127 const int height_without_buttons = GetUpdatedClientBounds().height(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 EXPECT_EQ(no_extra_view_size.width(), client_view()->bounds().width()); | 245 EXPECT_EQ(no_extra_view_size.width(), client_view()->bounds().width()); |
246 | 246 |
247 // Try with a reduced-size dialog. | 247 // Try with a reduced-size dialog. |
248 extra_view->SetVisible(true); | 248 extra_view->SetVisible(true); |
249 client_view()->SetBoundsRect(gfx::Rect(gfx::Point(0, 0), no_extra_view_size)); | 249 client_view()->SetBoundsRect(gfx::Rect(gfx::Point(0, 0), no_extra_view_size)); |
250 client_view()->Layout(); | 250 client_view()->Layout(); |
251 EXPECT_GT(width_of_extra_view, extra_view->bounds().width()); | 251 EXPECT_GT(width_of_extra_view, extra_view->bounds().width()); |
252 } | 252 } |
253 | 253 |
254 } // namespace views | 254 } // namespace views |
OLD | NEW |