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

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

Issue 1216673005: views::LabelButton should not call virtual methods from its constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150703-Views-ButtonBorderRefactor
Patch Set: self review Created 5 years, 5 months 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_client_view.cc ('k') | no next file » | 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"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 TEST_F(DialogTest, DefaultButtons) { 121 TEST_F(DialogTest, DefaultButtons) {
122 DialogClientView* client_view = dialog()->GetDialogClientView(); 122 DialogClientView* client_view = dialog()->GetDialogClientView();
123 LabelButton* ok_button = client_view->ok_button(); 123 LabelButton* ok_button = client_view->ok_button();
124 124
125 // DialogDelegate's default button (ok) should be default (and handle enter). 125 // DialogDelegate's default button (ok) should be default (and handle enter).
126 EXPECT_EQ(ui::DIALOG_BUTTON_OK, dialog()->GetDefaultDialogButton()); 126 EXPECT_EQ(ui::DIALOG_BUTTON_OK, dialog()->GetDefaultDialogButton());
127 dialog()->PressEnterAndCheckStates(ok_button); 127 dialog()->PressEnterAndCheckStates(ok_button);
128 128
129 // Focus another button in the dialog, it should become the default. 129 // Focus another button in the dialog, it should become the default.
130 LabelButton* button_1 = new LabelButton(dialog(), base::string16()); 130 LabelButton* button_1 = new LabelButton(dialog());
131 button_1->InitAsTextbutton(base::string16());
131 client_view->AddChildView(button_1); 132 client_view->AddChildView(button_1);
132 client_view->OnWillChangeFocus(ok_button, button_1); 133 client_view->OnWillChangeFocus(ok_button, button_1);
133 EXPECT_TRUE(button_1->is_default()); 134 EXPECT_TRUE(button_1->is_default());
134 dialog()->PressEnterAndCheckStates(button_1); 135 dialog()->PressEnterAndCheckStates(button_1);
135 136
136 // Focus a Checkbox (not a push button), OK should become the default again. 137 // Focus a Checkbox (not a push button), OK should become the default again.
137 Checkbox* checkbox = new Checkbox(base::string16()); 138 Checkbox* checkbox = new Checkbox(base::string16());
138 client_view->AddChildView(checkbox); 139 client_view->AddChildView(checkbox);
139 client_view->OnWillChangeFocus(button_1, checkbox); 140 client_view->OnWillChangeFocus(button_1, checkbox);
140 EXPECT_FALSE(button_1->is_default()); 141 EXPECT_FALSE(button_1->is_default());
141 dialog()->PressEnterAndCheckStates(ok_button); 142 dialog()->PressEnterAndCheckStates(ok_button);
142 143
143 // Focus yet another button in the dialog, it should become the default. 144 // Focus yet another button in the dialog, it should become the default.
144 LabelButton* button_2 = new LabelButton(dialog(), base::string16()); 145 LabelButton* button_2 = new LabelButton(dialog());
146 button_2->InitAsTextbutton(base::string16());
145 client_view->AddChildView(button_2); 147 client_view->AddChildView(button_2);
146 client_view->OnWillChangeFocus(checkbox, button_2); 148 client_view->OnWillChangeFocus(checkbox, button_2);
147 EXPECT_FALSE(button_1->is_default()); 149 EXPECT_FALSE(button_1->is_default());
148 EXPECT_TRUE(button_2->is_default()); 150 EXPECT_TRUE(button_2->is_default());
149 dialog()->PressEnterAndCheckStates(button_2); 151 dialog()->PressEnterAndCheckStates(button_2);
150 152
151 // Focus nothing, OK should become the default again. 153 // Focus nothing, OK should become the default again.
152 client_view->OnWillChangeFocus(button_2, NULL); 154 client_view->OnWillChangeFocus(button_2, NULL);
153 EXPECT_FALSE(button_1->is_default()); 155 EXPECT_FALSE(button_1->is_default());
154 EXPECT_FALSE(button_2->is_default()); 156 EXPECT_FALSE(button_2->is_default());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Giving the default test dialog a title will yield the same bounds. 256 // Giving the default test dialog a title will yield the same bounds.
255 dialog()->set_title(base::ASCIIToUTF16("Title")); 257 dialog()->set_title(base::ASCIIToUTF16("Title"));
256 dialog()->GetWidget()->UpdateWindowTitle(); 258 dialog()->GetWidget()->UpdateWindowTitle();
257 EXPECT_EQ(frame1->GetPreferredSize().height(), 259 EXPECT_EQ(frame1->GetPreferredSize().height(),
258 frame2->GetPreferredSize().height()); 260 frame2->GetPreferredSize().height());
259 261
260 dialog2->TearDown(); 262 dialog2->TearDown();
261 } 263 }
262 264
263 } // namespace views 265 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/window/dialog_client_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698