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

Unified Diff: ui/views/controls/button/label_button_unittest.cc

Issue 2143473002: [ash-md] Updates window title if it is changed after entering overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates LabelButton label size when text is changed Created 4 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/label_button_unittest.cc
diff --git a/ui/views/controls/button/label_button_unittest.cc b/ui/views/controls/button/label_button_unittest.cc
index 5c94c30fe039fb8fa5bb416bfcbfc86b3dffc632..702ed688f2baed7e54ea34a2995dd0b4e60ecd85 100644
--- a/ui/views/controls/button/label_button_unittest.cc
+++ b/ui/views/controls/button/label_button_unittest.cc
@@ -311,16 +311,29 @@ TEST_F(LabelButtonTest, ChangeTextSize) {
const base::string16 text(ASCIIToUTF16("abc"));
const base::string16 longer_text(ASCIIToUTF16("abcdefghijklm"));
button_->SetText(text);
-
+ button_->SizeToPreferredSize();
+ gfx::Rect bounds(button_->bounds());
const int original_width = button_->GetPreferredSize().width();
+ EXPECT_EQ(original_width, bounds.width());
+
+ // Reserve more space in the button.
+ bounds.set_width(bounds.width() * 10);
+ button_->SetBoundsRect(bounds);
- // The button size increases when the text size is increased.
+ // Label view in the button is sized to short text.
+ const int original_label_width = button_->label()->bounds().width();
+
+ // The button preferred size and the label size increase when the text size
+ // is increased.
button_->SetText(longer_text);
- EXPECT_GT(button_->GetPreferredSize().width(), original_width);
+ EXPECT_GT(button_->label()->bounds().width(), original_label_width * 2);
+ EXPECT_GT(button_->GetPreferredSize().width(), original_width * 2);
- // The button returns to its original size when the original text is restored.
+ // The button and the label view return to its original size when the original
+ // text is restored.
button_->SetMinSize(gfx::Size());
button_->SetText(text);
+ EXPECT_EQ(original_label_width, button_->label()->bounds().width());
EXPECT_EQ(original_width, button_->GetPreferredSize().width());
}
« 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