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

Side by Side Diff: ui/views/controls/button/custom_button_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/controls/button/checkbox.cc ('k') | ui/views/controls/button/label_button.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 (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 "ui/views/controls/button/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/base/layout.h" 8 #include "ui/base/layout.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/gfx/screen.h" 10 #include "ui/gfx/screen.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 PerformGesture(button(), ui::ET_GESTURE_TAP_CANCEL); 208 PerformGesture(button(), ui::ET_GESTURE_TAP_CANCEL);
209 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); 209 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state());
210 } 210 }
211 211
212 #endif // !defined(OS_MACOSX) || defined(USE_AURA) 212 #endif // !defined(OS_MACOSX) || defined(USE_AURA)
213 213
214 // Ensure subclasses of CustomButton are correctly recognized as CustomButton. 214 // Ensure subclasses of CustomButton are correctly recognized as CustomButton.
215 TEST_F(CustomButtonTest, AsCustomButton) { 215 TEST_F(CustomButtonTest, AsCustomButton) {
216 base::string16 text; 216 base::string16 text;
217 217
218 LabelButton label_button(NULL, text); 218 LabelButton label_button(nullptr);
219 label_button.InitAsTextbutton(text);
219 EXPECT_TRUE(CustomButton::AsCustomButton(&label_button)); 220 EXPECT_TRUE(CustomButton::AsCustomButton(&label_button));
220 221
221 ImageButton image_button(NULL); 222 ImageButton image_button(NULL);
222 EXPECT_TRUE(CustomButton::AsCustomButton(&image_button)); 223 EXPECT_TRUE(CustomButton::AsCustomButton(&image_button));
223 224
224 Checkbox checkbox(text); 225 Checkbox checkbox(text);
225 EXPECT_TRUE(CustomButton::AsCustomButton(&checkbox)); 226 EXPECT_TRUE(CustomButton::AsCustomButton(&checkbox));
226 227
227 RadioButton radio_button(text, 0); 228 RadioButton radio_button(text, 0);
228 EXPECT_TRUE(CustomButton::AsCustomButton(&radio_button)); 229 EXPECT_TRUE(CustomButton::AsCustomButton(&radio_button));
229 230
230 MenuButton menu_button(NULL, text, NULL, false); 231 MenuButton menu_button(NULL, text, NULL, false);
231 EXPECT_TRUE(CustomButton::AsCustomButton(&menu_button)); 232 EXPECT_TRUE(CustomButton::AsCustomButton(&menu_button));
232 233
233 Label label; 234 Label label;
234 EXPECT_FALSE(CustomButton::AsCustomButton(&label)); 235 EXPECT_FALSE(CustomButton::AsCustomButton(&label));
235 236
236 Link link(text); 237 Link link(text);
237 EXPECT_FALSE(CustomButton::AsCustomButton(&link)); 238 EXPECT_FALSE(CustomButton::AsCustomButton(&link));
238 239
239 Textfield textfield; 240 Textfield textfield;
240 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); 241 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield));
241 } 242 }
242 243
243 } // namespace views 244 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/checkbox.cc ('k') | ui/views/controls/button/label_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698