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

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

Issue 661033006: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « ui/views/window/dialog_delegate.h ('k') | ui/views/window/native_frame_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "ui/base/hit_test.h" 6 #include "ui/base/hit_test.h"
7 #include "ui/views/bubble/bubble_border.h" 7 #include "ui/views/bubble/bubble_border.h"
8 #include "ui/views/bubble/bubble_frame_view.h" 8 #include "ui/views/bubble/bubble_frame_view.h"
9 #include "ui/views/controls/button/checkbox.h" 9 #include "ui/views/controls/button/checkbox.h"
10 #include "ui/views/controls/button/label_button.h" 10 #include "ui/views/controls/button/label_button.h"
11 #include "ui/views/test/views_test_base.h" 11 #include "ui/views/test/views_test_base.h"
12 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
13 #include "ui/views/window/dialog_client_view.h" 13 #include "ui/views/window/dialog_client_view.h"
14 #include "ui/views/window/dialog_delegate.h" 14 #include "ui/views/window/dialog_delegate.h"
15 15
16 namespace views { 16 namespace views {
17 17
18 namespace { 18 namespace {
19 19
20 class TestDialog : public DialogDelegateView, public ButtonListener { 20 class TestDialog : public DialogDelegateView, public ButtonListener {
21 public: 21 public:
22 TestDialog() 22 TestDialog()
23 : canceled_(false), 23 : canceled_(false),
24 accepted_(false), 24 accepted_(false),
25 closeable_(false), 25 closeable_(false),
26 last_pressed_button_(NULL) {} 26 last_pressed_button_(NULL) {}
27 virtual ~TestDialog() {} 27 ~TestDialog() override {}
28 28
29 // DialogDelegateView overrides: 29 // DialogDelegateView overrides:
30 virtual bool Cancel() override { 30 bool Cancel() override {
31 canceled_ = true; 31 canceled_ = true;
32 return closeable_; 32 return closeable_;
33 } 33 }
34 virtual bool Accept() override { 34 bool Accept() override {
35 accepted_ = true; 35 accepted_ = true;
36 return closeable_; 36 return closeable_;
37 } 37 }
38 38
39 // DialogDelegateView overrides: 39 // DialogDelegateView overrides:
40 virtual gfx::Size GetPreferredSize() const override { 40 gfx::Size GetPreferredSize() const override { return gfx::Size(200, 200); }
41 return gfx::Size(200, 200); 41 base::string16 GetWindowTitle() const override { return title_; }
42 } 42 bool UseNewStyleForThisDialog() const override { return true; }
43 virtual base::string16 GetWindowTitle() const override { return title_; }
44 virtual bool UseNewStyleForThisDialog() const override { return true; }
45 43
46 // ButtonListener override: 44 // ButtonListener override:
47 virtual void ButtonPressed(Button* sender, const ui::Event& event) override { 45 void ButtonPressed(Button* sender, const ui::Event& event) override {
48 last_pressed_button_ = sender; 46 last_pressed_button_ = sender;
49 } 47 }
50 48
51 Button* last_pressed_button() const { return last_pressed_button_; } 49 Button* last_pressed_button() const { return last_pressed_button_; }
52 50
53 void PressEnterAndCheckStates(Button* button) { 51 void PressEnterAndCheckStates(Button* button) {
54 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE); 52 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE);
55 GetFocusManager()->OnKeyEvent(key_event); 53 GetFocusManager()->OnKeyEvent(key_event);
56 const DialogClientView* client_view = GetDialogClientView(); 54 const DialogClientView* client_view = GetDialogClientView();
57 EXPECT_EQ(canceled_, client_view->cancel_button()->is_default()); 55 EXPECT_EQ(canceled_, client_view->cancel_button()->is_default());
(...skipping 27 matching lines...) Expand all
85 bool closeable_; 83 bool closeable_;
86 Button* last_pressed_button_; 84 Button* last_pressed_button_;
87 base::string16 title_; 85 base::string16 title_;
88 86
89 DISALLOW_COPY_AND_ASSIGN(TestDialog); 87 DISALLOW_COPY_AND_ASSIGN(TestDialog);
90 }; 88 };
91 89
92 class DialogTest : public ViewsTestBase { 90 class DialogTest : public ViewsTestBase {
93 public: 91 public:
94 DialogTest() : dialog_(NULL) {} 92 DialogTest() : dialog_(NULL) {}
95 virtual ~DialogTest() {} 93 ~DialogTest() override {}
96 94
97 virtual void SetUp() override { 95 void SetUp() override {
98 ViewsTestBase::SetUp(); 96 ViewsTestBase::SetUp();
99 dialog_ = new TestDialog(); 97 dialog_ = new TestDialog();
100 DialogDelegate::CreateDialogWidget(dialog_, GetContext(), NULL)->Show(); 98 DialogDelegate::CreateDialogWidget(dialog_, GetContext(), NULL)->Show();
101 } 99 }
102 100
103 virtual void TearDown() override { 101 void TearDown() override {
104 dialog_->TearDown(); 102 dialog_->TearDown();
105 ViewsTestBase::TearDown(); 103 ViewsTestBase::TearDown();
106 } 104 }
107 105
108 TestDialog* dialog() const { return dialog_; } 106 TestDialog* dialog() const { return dialog_; }
109 107
110 private: 108 private:
111 TestDialog* dialog_; 109 TestDialog* dialog_;
112 110
113 DISALLOW_COPY_AND_ASSIGN(DialogTest); 111 DISALLOW_COPY_AND_ASSIGN(DialogTest);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 frame2->GetPreferredSize().height()); 220 frame2->GetPreferredSize().height());
223 221
224 // Giving the default test dialog a title will yield the same bounds. 222 // Giving the default test dialog a title will yield the same bounds.
225 dialog()->set_title(base::ASCIIToUTF16("Title")); 223 dialog()->set_title(base::ASCIIToUTF16("Title"));
226 dialog()->GetWidget()->UpdateWindowTitle(); 224 dialog()->GetWidget()->UpdateWindowTitle();
227 EXPECT_EQ(frame1->GetPreferredSize().height(), 225 EXPECT_EQ(frame1->GetPreferredSize().height(),
228 frame2->GetPreferredSize().height()); 226 frame2->GetPreferredSize().height());
229 } 227 }
230 228
231 } // namespace views 229 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/window/dialog_delegate.h ('k') | ui/views/window/native_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698