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

Side by Side Diff: ui/views/controls/button/label_button_unittest.cc

Issue 1228213003: Just set borders once when creating a views::LabelButton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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/label_button.h" 5 #include "ui/views/controls/button/label_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "ui/accessibility/ax_view_state.h"
9 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/font_list.h" 11 #include "ui/gfx/font_list.h"
11 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
12 #include "ui/gfx/text_utils.h" 13 #include "ui/gfx/text_utils.h"
13 #include "ui/views/test/views_test_base.h" 14 #include "ui/views/test/widget_test.h"
14 15
15 using base::ASCIIToUTF16; 16 using base::ASCIIToUTF16;
16 17
17 namespace { 18 namespace {
18 19
19 gfx::ImageSkia CreateTestImage(int width, int height) { 20 gfx::ImageSkia CreateTestImage(int width, int height) {
20 SkBitmap bitmap; 21 SkBitmap bitmap;
21 bitmap.allocN32Pixels(width, height); 22 bitmap.allocN32Pixels(width, height);
22 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 23 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
23 } 24 }
24 25
25 } // namespace 26 } // namespace
26 27
27 namespace views { 28 namespace views {
28 29
29 typedef ViewsTestBase LabelButtonTest; 30 class LabelButtonTest : public test::WidgetTest {
31 public:
32 LabelButtonTest() {}
33
34 // testing::Test:
35 void SetUp() override {
36 WidgetTest::SetUp();
37 // Make a Widget to host the button. This ensures appropriate borders are
38 // used (which could be derived from the Widget's NativeTheme).
39 test_widget_ = CreateTopLevelPlatformWidget();
40
41 button_ = new LabelButton(nullptr, base::string16());
42 test_widget_->GetContentsView()->AddChildView(button_);
43 }
44
45 void TearDown() override {
46 test_widget_->CloseNow();
47 WidgetTest::TearDown();
48 }
49
50 protected:
51 LabelButton* button_ = nullptr;
52
53 private:
54 Widget* test_widget_ = nullptr;
55
56 DISALLOW_COPY_AND_ASSIGN(LabelButtonTest);
57 };
30 58
31 TEST_F(LabelButtonTest, Init) { 59 TEST_F(LabelButtonTest, Init) {
32 const base::string16 text(ASCIIToUTF16("abc")); 60 const base::string16 text(ASCIIToUTF16("abc"));
33 LabelButton button(NULL, text); 61 LabelButton button(NULL, text);
34 62
35 EXPECT_TRUE(button.GetImage(Button::STATE_NORMAL).isNull()); 63 EXPECT_TRUE(button.GetImage(Button::STATE_NORMAL).isNull());
36 EXPECT_TRUE(button.GetImage(Button::STATE_HOVERED).isNull()); 64 EXPECT_TRUE(button.GetImage(Button::STATE_HOVERED).isNull());
37 EXPECT_TRUE(button.GetImage(Button::STATE_PRESSED).isNull()); 65 EXPECT_TRUE(button.GetImage(Button::STATE_PRESSED).isNull());
38 EXPECT_TRUE(button.GetImage(Button::STATE_DISABLED).isNull()); 66 EXPECT_TRUE(button.GetImage(Button::STATE_DISABLED).isNull());
39 67
40 EXPECT_EQ(text, button.GetText()); 68 EXPECT_EQ(text, button.GetText());
69
70 ui::AXViewState accessible_state;
71 button.GetAccessibleState(&accessible_state);
72 EXPECT_EQ(ui::AX_ROLE_BUTTON, accessible_state.role);
73 EXPECT_EQ(text, accessible_state.name);
74
41 EXPECT_EQ(gfx::ALIGN_LEFT, button.GetHorizontalAlignment()); 75 EXPECT_EQ(gfx::ALIGN_LEFT, button.GetHorizontalAlignment());
42 EXPECT_FALSE(button.is_default()); 76 EXPECT_FALSE(button.is_default());
43 EXPECT_EQ(button.style(), Button::STYLE_TEXTBUTTON); 77 EXPECT_EQ(button.style(), Button::STYLE_TEXTBUTTON);
44 EXPECT_EQ(Button::STATE_NORMAL, button.state()); 78 EXPECT_EQ(Button::STATE_NORMAL, button.state());
45 79
46 EXPECT_EQ(button.image_->parent(), &button); 80 EXPECT_EQ(button.image_->parent(), &button);
47 EXPECT_EQ(button.label_->parent(), &button); 81 EXPECT_EQ(button.label_->parent(), &button);
48 } 82 }
49 83
50 TEST_F(LabelButtonTest, Label) { 84 TEST_F(LabelButtonTest, Label) {
51 LabelButton button(NULL, base::string16()); 85 EXPECT_TRUE(button_->GetText().empty());
52 EXPECT_TRUE(button.GetText().empty());
53 86
54 const gfx::FontList font_list; 87 const gfx::FontList font_list;
55 const base::string16 short_text(ASCIIToUTF16("abcdefghijklm")); 88 const base::string16 short_text(ASCIIToUTF16("abcdefghijklm"));
56 const base::string16 long_text(ASCIIToUTF16("abcdefghijklmnopqrstuvwxyz")); 89 const base::string16 long_text(ASCIIToUTF16("abcdefghijklmnopqrstuvwxyz"));
57 const int short_text_width = gfx::GetStringWidth(short_text, font_list); 90 const int short_text_width = gfx::GetStringWidth(short_text, font_list);
58 const int long_text_width = gfx::GetStringWidth(long_text, font_list); 91 const int long_text_width = gfx::GetStringWidth(long_text, font_list);
59 92
60 // The width increases monotonically with string size (it does not shrink). 93 // The width increases monotonically with string size (it does not shrink).
61 EXPECT_LT(button.GetPreferredSize().width(), short_text_width); 94 EXPECT_LT(button_->GetPreferredSize().width(), short_text_width);
62 button.SetText(short_text); 95 button_->SetText(short_text);
63 EXPECT_GT(button.GetPreferredSize().height(), font_list.GetHeight()); 96 EXPECT_GT(button_->GetPreferredSize().height(), font_list.GetHeight());
64 EXPECT_GT(button.GetPreferredSize().width(), short_text_width); 97 EXPECT_GT(button_->GetPreferredSize().width(), short_text_width);
65 EXPECT_LT(button.GetPreferredSize().width(), long_text_width); 98 EXPECT_LT(button_->GetPreferredSize().width(), long_text_width);
66 button.SetText(long_text); 99 button_->SetText(long_text);
67 EXPECT_GT(button.GetPreferredSize().width(), long_text_width); 100 EXPECT_GT(button_->GetPreferredSize().width(), long_text_width);
68 button.SetText(short_text); 101 button_->SetText(short_text);
69 EXPECT_GT(button.GetPreferredSize().width(), long_text_width); 102 EXPECT_GT(button_->GetPreferredSize().width(), long_text_width);
70 103
71 // Clamp the size to a maximum value. 104 // Clamp the size to a maximum value.
72 button.SetMaxSize(gfx::Size(long_text_width, 1)); 105 button_->SetMaxSize(gfx::Size(long_text_width, 1));
73 EXPECT_EQ(button.GetPreferredSize(), gfx::Size(long_text_width, 1)); 106 EXPECT_EQ(button_->GetPreferredSize(), gfx::Size(long_text_width, 1));
74 107
75 // Clear the monotonically increasing minimum size. 108 // Clear the monotonically increasing minimum size.
76 button.SetMinSize(gfx::Size()); 109 button_->SetMinSize(gfx::Size());
77 EXPECT_GT(button.GetPreferredSize().width(), short_text_width); 110 EXPECT_GT(button_->GetPreferredSize().width(), short_text_width);
78 EXPECT_LT(button.GetPreferredSize().width(), long_text_width); 111 EXPECT_LT(button_->GetPreferredSize().width(), long_text_width);
112 }
113
114 // Test behavior of View::GetAccessibleState() for buttons when setting a label.
115 TEST_F(LabelButtonTest, AccessibleState) {
116 ui::AXViewState accessible_state;
117
118 button_->GetAccessibleState(&accessible_state);
119 EXPECT_EQ(ui::AX_ROLE_BUTTON, accessible_state.role);
120 EXPECT_EQ(base::string16(), accessible_state.name);
121
122 // Without a label (e.g. image-only), the accessible name should automatically
123 // be set from the tooltip.
124 const base::string16 tooltip_text = ASCIIToUTF16("abc");
125 button_->SetTooltipText(tooltip_text);
126 button_->GetAccessibleState(&accessible_state);
127 EXPECT_EQ(tooltip_text, accessible_state.name);
128 EXPECT_EQ(base::string16(), button_->GetText());
129
130 // Setting a label overrides the tooltip text.
131 const base::string16 label_text = ASCIIToUTF16("def");
132 button_->SetText(label_text);
133 button_->GetAccessibleState(&accessible_state);
134 EXPECT_EQ(label_text, accessible_state.name);
135 EXPECT_EQ(label_text, button_->GetText());
136
137 base::string16 tooltip;
138 EXPECT_TRUE(button_->GetTooltipText(gfx::Point(), &tooltip));
139 EXPECT_EQ(tooltip_text, tooltip);
79 } 140 }
80 141
81 TEST_F(LabelButtonTest, Image) { 142 TEST_F(LabelButtonTest, Image) {
82 LabelButton button(NULL, base::string16());
83
84 const int small_size = 50, large_size = 100; 143 const int small_size = 50, large_size = 100;
85 const gfx::ImageSkia small_image = CreateTestImage(small_size, small_size); 144 const gfx::ImageSkia small_image = CreateTestImage(small_size, small_size);
86 const gfx::ImageSkia large_image = CreateTestImage(large_size, large_size); 145 const gfx::ImageSkia large_image = CreateTestImage(large_size, large_size);
87 146
88 // The width increases monotonically with image size (it does not shrink). 147 // The width increases monotonically with image size (it does not shrink).
89 EXPECT_LT(button.GetPreferredSize().width(), small_size); 148 EXPECT_LT(button_->GetPreferredSize().width(), small_size);
90 EXPECT_LT(button.GetPreferredSize().height(), small_size); 149 EXPECT_LT(button_->GetPreferredSize().height(), small_size);
91 button.SetImage(Button::STATE_NORMAL, small_image); 150 button_->SetImage(Button::STATE_NORMAL, small_image);
92 EXPECT_GT(button.GetPreferredSize().width(), small_size); 151 EXPECT_GT(button_->GetPreferredSize().width(), small_size);
93 EXPECT_GT(button.GetPreferredSize().height(), small_size); 152 EXPECT_GT(button_->GetPreferredSize().height(), small_size);
94 EXPECT_LT(button.GetPreferredSize().width(), large_size); 153 EXPECT_LT(button_->GetPreferredSize().width(), large_size);
95 EXPECT_LT(button.GetPreferredSize().height(), large_size); 154 EXPECT_LT(button_->GetPreferredSize().height(), large_size);
96 button.SetImage(Button::STATE_NORMAL, large_image); 155 button_->SetImage(Button::STATE_NORMAL, large_image);
97 EXPECT_GT(button.GetPreferredSize().width(), large_size); 156 EXPECT_GT(button_->GetPreferredSize().width(), large_size);
98 EXPECT_GT(button.GetPreferredSize().height(), large_size); 157 EXPECT_GT(button_->GetPreferredSize().height(), large_size);
99 button.SetImage(Button::STATE_NORMAL, small_image); 158 button_->SetImage(Button::STATE_NORMAL, small_image);
100 EXPECT_GT(button.GetPreferredSize().width(), large_size); 159 EXPECT_GT(button_->GetPreferredSize().width(), large_size);
101 EXPECT_GT(button.GetPreferredSize().height(), large_size); 160 EXPECT_GT(button_->GetPreferredSize().height(), large_size);
102 161
103 // Clamp the size to a maximum value. 162 // Clamp the size to a maximum value.
104 button.SetMaxSize(gfx::Size(large_size, 1)); 163 button_->SetMaxSize(gfx::Size(large_size, 1));
105 EXPECT_EQ(button.GetPreferredSize(), gfx::Size(large_size, 1)); 164 EXPECT_EQ(button_->GetPreferredSize(), gfx::Size(large_size, 1));
106 165
107 // Clear the monotonically increasing minimum size. 166 // Clear the monotonically increasing minimum size.
108 button.SetMinSize(gfx::Size()); 167 button_->SetMinSize(gfx::Size());
109 EXPECT_GT(button.GetPreferredSize().width(), small_size); 168 EXPECT_GT(button_->GetPreferredSize().width(), small_size);
110 EXPECT_LT(button.GetPreferredSize().width(), large_size); 169 EXPECT_LT(button_->GetPreferredSize().width(), large_size);
111 } 170 }
112 171
113 TEST_F(LabelButtonTest, LabelAndImage) { 172 TEST_F(LabelButtonTest, LabelAndImage) {
114 LabelButton button(NULL, base::string16());
115
116 const gfx::FontList font_list; 173 const gfx::FontList font_list;
117 const base::string16 text(ASCIIToUTF16("abcdefghijklm")); 174 const base::string16 text(ASCIIToUTF16("abcdefghijklm"));
118 const int text_width = gfx::GetStringWidth(text, font_list); 175 const int text_width = gfx::GetStringWidth(text, font_list);
119 176
120 const int image_size = 50; 177 const int image_size = 50;
121 const gfx::ImageSkia image = CreateTestImage(image_size, image_size); 178 const gfx::ImageSkia image = CreateTestImage(image_size, image_size);
122 ASSERT_LT(font_list.GetHeight(), image_size); 179 ASSERT_LT(font_list.GetHeight(), image_size);
123 180
124 // The width increases monotonically with content size (it does not shrink). 181 // The width increases monotonically with content size (it does not shrink).
125 EXPECT_LT(button.GetPreferredSize().width(), text_width); 182 EXPECT_LT(button_->GetPreferredSize().width(), text_width);
126 EXPECT_LT(button.GetPreferredSize().width(), image_size); 183 EXPECT_LT(button_->GetPreferredSize().width(), image_size);
127 EXPECT_LT(button.GetPreferredSize().height(), image_size); 184 EXPECT_LT(button_->GetPreferredSize().height(), image_size);
128 button.SetText(text); 185 button_->SetText(text);
129 EXPECT_GT(button.GetPreferredSize().width(), text_width); 186 EXPECT_GT(button_->GetPreferredSize().width(), text_width);
130 EXPECT_GT(button.GetPreferredSize().height(), font_list.GetHeight()); 187 EXPECT_GT(button_->GetPreferredSize().height(), font_list.GetHeight());
131 EXPECT_LT(button.GetPreferredSize().width(), text_width + image_size); 188 EXPECT_LT(button_->GetPreferredSize().width(), text_width + image_size);
132 EXPECT_LT(button.GetPreferredSize().height(), image_size); 189 EXPECT_LT(button_->GetPreferredSize().height(), image_size);
133 button.SetImage(Button::STATE_NORMAL, image); 190 button_->SetImage(Button::STATE_NORMAL, image);
134 EXPECT_GT(button.GetPreferredSize().width(), text_width + image_size); 191 EXPECT_GT(button_->GetPreferredSize().width(), text_width + image_size);
135 EXPECT_GT(button.GetPreferredSize().height(), image_size); 192 EXPECT_GT(button_->GetPreferredSize().height(), image_size);
136 193
137 // Layout and ensure the image is left of the label except for ALIGN_RIGHT. 194 // Layout and ensure the image is left of the label except for ALIGN_RIGHT.
138 // (A proper parent view or layout manager would Layout on its invalidations). 195 // (A proper parent view or layout manager would Layout on its invalidations).
139 button.SetSize(button.GetPreferredSize()); 196 button_->SetSize(button_->GetPreferredSize());
140 button.Layout(); 197 button_->Layout();
141 EXPECT_EQ(gfx::ALIGN_LEFT, button.GetHorizontalAlignment()); 198 EXPECT_EQ(gfx::ALIGN_LEFT, button_->GetHorizontalAlignment());
142 EXPECT_LT(button.image_->bounds().right(), button.label_->bounds().x()); 199 EXPECT_LT(button_->image_->bounds().right(), button_->label_->bounds().x());
143 button.SetHorizontalAlignment(gfx::ALIGN_CENTER); 200 button_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
144 button.Layout(); 201 button_->Layout();
145 EXPECT_EQ(gfx::ALIGN_CENTER, button.GetHorizontalAlignment()); 202 EXPECT_EQ(gfx::ALIGN_CENTER, button_->GetHorizontalAlignment());
146 EXPECT_LT(button.image_->bounds().right(), button.label_->bounds().x()); 203 EXPECT_LT(button_->image_->bounds().right(), button_->label_->bounds().x());
147 button.SetHorizontalAlignment(gfx::ALIGN_RIGHT); 204 button_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
148 button.Layout(); 205 button_->Layout();
149 EXPECT_EQ(gfx::ALIGN_RIGHT, button.GetHorizontalAlignment()); 206 EXPECT_EQ(gfx::ALIGN_RIGHT, button_->GetHorizontalAlignment());
150 EXPECT_LT(button.label_->bounds().right(), button.image_->bounds().x()); 207 EXPECT_LT(button_->label_->bounds().right(), button_->image_->bounds().x());
151 208
152 button.SetText(base::string16()); 209 button_->SetText(base::string16());
153 EXPECT_GT(button.GetPreferredSize().width(), text_width + image_size); 210 EXPECT_GT(button_->GetPreferredSize().width(), text_width + image_size);
154 EXPECT_GT(button.GetPreferredSize().height(), image_size); 211 EXPECT_GT(button_->GetPreferredSize().height(), image_size);
155 button.SetImage(Button::STATE_NORMAL, gfx::ImageSkia()); 212 button_->SetImage(Button::STATE_NORMAL, gfx::ImageSkia());
156 EXPECT_GT(button.GetPreferredSize().width(), text_width + image_size); 213 EXPECT_GT(button_->GetPreferredSize().width(), text_width + image_size);
157 EXPECT_GT(button.GetPreferredSize().height(), image_size); 214 EXPECT_GT(button_->GetPreferredSize().height(), image_size);
158 215
159 // Clamp the size to a maximum value. 216 // Clamp the size to a maximum value.
160 button.SetMaxSize(gfx::Size(image_size, 1)); 217 button_->SetMaxSize(gfx::Size(image_size, 1));
161 EXPECT_EQ(button.GetPreferredSize(), gfx::Size(image_size, 1)); 218 EXPECT_EQ(button_->GetPreferredSize(), gfx::Size(image_size, 1));
162 219
163 // Clear the monotonically increasing minimum size. 220 // Clear the monotonically increasing minimum size.
164 button.SetMinSize(gfx::Size()); 221 button_->SetMinSize(gfx::Size());
165 EXPECT_LT(button.GetPreferredSize().width(), text_width); 222 EXPECT_LT(button_->GetPreferredSize().width(), text_width);
166 EXPECT_LT(button.GetPreferredSize().width(), image_size); 223 EXPECT_LT(button_->GetPreferredSize().width(), image_size);
167 EXPECT_LT(button.GetPreferredSize().height(), image_size); 224 EXPECT_LT(button_->GetPreferredSize().height(), image_size);
168 } 225 }
169 226
170 TEST_F(LabelButtonTest, FontList) { 227 TEST_F(LabelButtonTest, FontList) {
171 const base::string16 text(ASCIIToUTF16("abc")); 228 button_->SetText(base::ASCIIToUTF16("abc"));
172 LabelButton button(NULL, text);
173 229
174 const gfx::FontList original_font_list = button.GetFontList(); 230 const gfx::FontList original_font_list = button_->GetFontList();
175 const gfx::FontList large_font_list = 231 const gfx::FontList large_font_list =
176 original_font_list.DeriveWithSizeDelta(100); 232 original_font_list.DeriveWithSizeDelta(100);
177 const int original_width = button.GetPreferredSize().width(); 233 const int original_width = button_->GetPreferredSize().width();
178 const int original_height = button.GetPreferredSize().height(); 234 const int original_height = button_->GetPreferredSize().height();
179 235
180 // The button size increases when the font size is increased. 236 // The button size increases when the font size is increased.
181 button.SetFontList(large_font_list); 237 button_->SetFontList(large_font_list);
182 EXPECT_GT(button.GetPreferredSize().width(), original_width); 238 EXPECT_GT(button_->GetPreferredSize().width(), original_width);
183 EXPECT_GT(button.GetPreferredSize().height(), original_height); 239 EXPECT_GT(button_->GetPreferredSize().height(), original_height);
184 240
185 // The button returns to its original size when the minimal size is cleared 241 // The button returns to its original size when the minimal size is cleared
186 // and the original font size is restored. 242 // and the original font size is restored.
187 button.SetMinSize(gfx::Size()); 243 button_->SetMinSize(gfx::Size());
188 button.SetFontList(original_font_list); 244 button_->SetFontList(original_font_list);
189 EXPECT_EQ(original_width, button.GetPreferredSize().width()); 245 EXPECT_EQ(original_width, button_->GetPreferredSize().width());
190 EXPECT_EQ(original_height, button.GetPreferredSize().height()); 246 EXPECT_EQ(original_height, button_->GetPreferredSize().height());
191 } 247 }
192 248
193 TEST_F(LabelButtonTest, ChangeTextSize) { 249 TEST_F(LabelButtonTest, ChangeTextSize) {
194 const base::string16 text(ASCIIToUTF16("abc")); 250 const base::string16 text(ASCIIToUTF16("abc"));
195 const base::string16 longer_text(ASCIIToUTF16("abcdefghijklm")); 251 const base::string16 longer_text(ASCIIToUTF16("abcdefghijklm"));
196 LabelButton button(NULL, text); 252 button_->SetText(text);
197 253
198 const int original_width = button.GetPreferredSize().width(); 254 const int original_width = button_->GetPreferredSize().width();
199 255
200 // The button size increases when the text size is increased. 256 // The button size increases when the text size is increased.
201 button.SetText(longer_text); 257 button_->SetText(longer_text);
202 EXPECT_GT(button.GetPreferredSize().width(), original_width); 258 EXPECT_GT(button_->GetPreferredSize().width(), original_width);
203 259
204 // The button returns to its original size when the original text is restored. 260 // The button returns to its original size when the original text is restored.
205 button.SetMinSize(gfx::Size()); 261 button_->SetMinSize(gfx::Size());
206 button.SetText(text); 262 button_->SetText(text);
207 EXPECT_EQ(original_width, button.GetPreferredSize().width()); 263 EXPECT_EQ(original_width, button_->GetPreferredSize().width());
208 } 264 }
209 265
210 TEST_F(LabelButtonTest, ChangeLabelImageSpacing) { 266 TEST_F(LabelButtonTest, ChangeLabelImageSpacing) {
211 LabelButton button(NULL, ASCIIToUTF16("abc")); 267 button_->SetText(ASCIIToUTF16("abc"));
212 button.SetImage(Button::STATE_NORMAL, CreateTestImage(50, 50)); 268 button_->SetImage(Button::STATE_NORMAL, CreateTestImage(50, 50));
213 269
214 const int kOriginalSpacing = 5; 270 const int kOriginalSpacing = 5;
215 button.SetImageLabelSpacing(kOriginalSpacing); 271 button_->SetImageLabelSpacing(kOriginalSpacing);
216 const int original_width = button.GetPreferredSize().width(); 272 const int original_width = button_->GetPreferredSize().width();
217 273
218 // Increasing the spacing between the text and label should increase the size. 274 // Increasing the spacing between the text and label should increase the size.
219 button.SetImageLabelSpacing(2 * kOriginalSpacing); 275 button_->SetImageLabelSpacing(2 * kOriginalSpacing);
220 EXPECT_GT(button.GetPreferredSize().width(), original_width); 276 EXPECT_GT(button_->GetPreferredSize().width(), original_width);
221 277
222 // The button shrinks if the original spacing is restored. 278 // The button shrinks if the original spacing is restored.
223 button.SetMinSize(gfx::Size()); 279 button_->SetMinSize(gfx::Size());
224 button.SetImageLabelSpacing(kOriginalSpacing); 280 button_->SetImageLabelSpacing(kOriginalSpacing);
225 EXPECT_EQ(original_width, button.GetPreferredSize().width()); 281 EXPECT_EQ(original_width, button_->GetPreferredSize().width());
226 } 282 }
227 283
228 } // namespace views 284 } // namespace views
OLDNEW
« ui/views/controls/button/label_button.cc ('K') | « ui/views/controls/button/label_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698