| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "ui/base/ui_base_types.h" | 7 #include "ui/base/ui_base_types.h" |
| 8 #include "ui/views/controls/button/label_button.h" | 8 #include "ui/views/controls/button/label_button.h" |
| 9 #include "ui/views/test/test_views.h" | 9 #include "ui/views/test/test_views.h" |
| 10 #include "ui/views/test/views_test_base.h" | 10 #include "ui/views/test/views_test_base.h" |
| 11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 12 #include "ui/views/window/dialog_client_view.h" | 12 #include "ui/views/window/dialog_client_view.h" |
| 13 #include "ui/views/window/dialog_delegate.h" | 13 #include "ui/views/window/dialog_delegate.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 class TestDialogClientView : public DialogClientView { | 17 class TestDialogClientView : public DialogClientView { |
| 18 public: | 18 public: |
| 19 TestDialogClientView(View* contents_view, | 19 TestDialogClientView(View* contents_view, |
| 20 DialogDelegate* dialog_delegate) | 20 DialogDelegate* dialog_delegate) |
| 21 : DialogClientView(contents_view), | 21 : DialogClientView(contents_view), |
| 22 dialog_(dialog_delegate) {} | 22 dialog_(dialog_delegate) {} |
| 23 virtual ~TestDialogClientView() {} | 23 virtual ~TestDialogClientView() {} |
| 24 | 24 |
| 25 // DialogClientView implementation. | 25 // DialogClientView implementation. |
| 26 virtual DialogDelegate* GetDialogDelegate() const OVERRIDE { return dialog_; } | 26 virtual DialogDelegate* GetDialogDelegate() const override { return dialog_; } |
| 27 | 27 |
| 28 View* GetContentsView() { return contents_view(); } | 28 View* GetContentsView() { return contents_view(); } |
| 29 | 29 |
| 30 void CreateExtraViews() { | 30 void CreateExtraViews() { |
| 31 CreateExtraView(); | 31 CreateExtraView(); |
| 32 CreateFootnoteView(); | 32 CreateFootnoteView(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 DialogDelegate* dialog_; | 36 DialogDelegate* dialog_; |
| 37 | 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(TestDialogClientView); | 38 DISALLOW_COPY_AND_ASSIGN(TestDialogClientView); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 class DialogClientViewTest : public ViewsTestBase, | 41 class DialogClientViewTest : public ViewsTestBase, |
| 42 public DialogDelegateView { | 42 public DialogDelegateView { |
| 43 public: | 43 public: |
| 44 DialogClientViewTest() | 44 DialogClientViewTest() |
| 45 : dialog_buttons_(ui::DIALOG_BUTTON_NONE), | 45 : dialog_buttons_(ui::DIALOG_BUTTON_NONE), |
| 46 extra_view_(NULL), | 46 extra_view_(NULL), |
| 47 footnote_view_(NULL) {} | 47 footnote_view_(NULL) {} |
| 48 virtual ~DialogClientViewTest() {} | 48 virtual ~DialogClientViewTest() {} |
| 49 | 49 |
| 50 // testing::Test implementation. | 50 // testing::Test implementation. |
| 51 virtual void SetUp() OVERRIDE { | 51 virtual void SetUp() override { |
| 52 dialog_buttons_ = ui::DIALOG_BUTTON_NONE; | 52 dialog_buttons_ = ui::DIALOG_BUTTON_NONE; |
| 53 contents_.reset(new StaticSizedView(gfx::Size(100, 200))); | 53 contents_.reset(new StaticSizedView(gfx::Size(100, 200))); |
| 54 client_view_.reset(new TestDialogClientView(contents_.get(), this)); | 54 client_view_.reset(new TestDialogClientView(contents_.get(), this)); |
| 55 | 55 |
| 56 ViewsTestBase::SetUp(); | 56 ViewsTestBase::SetUp(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // DialogDelegateView implementation. | 59 // DialogDelegateView implementation. |
| 60 virtual View* GetContentsView() OVERRIDE { return contents_.get(); } | 60 virtual View* GetContentsView() override { return contents_.get(); } |
| 61 virtual View* CreateExtraView() OVERRIDE { return extra_view_; } | 61 virtual View* CreateExtraView() override { return extra_view_; } |
| 62 virtual View* CreateFootnoteView() OVERRIDE { return footnote_view_; } | 62 virtual View* CreateFootnoteView() override { return footnote_view_; } |
| 63 virtual int GetDialogButtons() const OVERRIDE { return dialog_buttons_; } | 63 virtual int GetDialogButtons() const override { return dialog_buttons_; } |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 gfx::Rect GetUpdatedClientBounds() { | 66 gfx::Rect GetUpdatedClientBounds() { |
| 67 client_view_->SizeToPreferredSize(); | 67 client_view_->SizeToPreferredSize(); |
| 68 client_view_->Layout(); | 68 client_view_->Layout(); |
| 69 return client_view_->bounds(); | 69 return client_view_->bounds(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Makes sure that the content view is sized correctly. Width must be at least | 72 // Makes sure that the content view is sized correctly. Width must be at least |
| 73 // the requested amount, but height should always match exactly. | 73 // the requested amount, but height should always match exactly. |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // Test that the FocusManager is properly cleared when the DialogClientView is | 283 // Test that the FocusManager is properly cleared when the DialogClientView is |
| 284 // removed from |dialog| during the widget's destruction. | 284 // removed from |dialog| during the widget's destruction. |
| 285 client_view->set_owned_by_client(); | 285 client_view->set_owned_by_client(); |
| 286 scoped_ptr<DialogClientView> owned_client_view(client_view); | 286 scoped_ptr<DialogClientView> owned_client_view(client_view); |
| 287 toplevel1->CloseNow(); | 287 toplevel1->CloseNow(); |
| 288 toplevel2->CloseNow(); | 288 toplevel2->CloseNow(); |
| 289 EXPECT_EQ(NULL, owned_client_view->focus_manager_); | 289 EXPECT_EQ(NULL, owned_client_view->focus_manager_); |
| 290 } | 290 } |
| 291 | 291 |
| 292 } // namespace views | 292 } // namespace views |
| OLD | NEW |