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

Unified Diff: ui/views/controls/styled_label_unittest.cc

Issue 258063009: retry r266622: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert Label changes completely Created 6 years, 8 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
« no previous file with comments | « ui/views/controls/scroll_view.cc ('k') | ui/views/controls/textfield/textfield.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/styled_label_unittest.cc
diff --git a/ui/views/controls/styled_label_unittest.cc b/ui/views/controls/styled_label_unittest.cc
index 2200c0b33d770f4952df966238c8e87c4201406e..d360aedb1b02d9fdd3b2b3143ffed75d388063a7 100644
--- a/ui/views/controls/styled_label_unittest.cc
+++ b/ui/views/controls/styled_label_unittest.cc
@@ -14,12 +14,14 @@
#include "ui/views/controls/link.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/controls/styled_label_listener.h"
+#include "ui/views/test/views_test_base.h"
+#include "ui/views/widget/widget.h"
using base::ASCIIToUTF16;
namespace views {
-class StyledLabelTest : public testing::Test, public StyledLabelListener {
+class StyledLabelTest : public ViewsTestBase, public StyledLabelListener {
public:
StyledLabelTest() {}
virtual ~StyledLabelTest() {}
@@ -292,16 +294,25 @@ TEST_F(StyledLabelTest, Color) {
text_red.size() + text_link.size()),
style_info_link);
+ styled()->SetBounds(0, 0, 1000, 1000);
+ styled()->Layout();
+
+ Widget* widget = new Widget();
+ Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
+ widget->Init(params);
+ View* container = new View();
+ widget->SetContentsView(container);
+ container->AddChildView(styled());
+
// Obtain the default text color for a label.
- Label label(ASCIIToUTF16(text));
- const SkColor kDefaultTextColor = label.enabled_color();
+ Label* label = new Label(ASCIIToUTF16(text));
+ container->AddChildView(label);
+ const SkColor kDefaultTextColor = label->enabled_color();
// Obtain the default text color for a link;
- Link link(ASCIIToUTF16(text_link));
- const SkColor kDefaultLinkColor = link.enabled_color();
-
- styled()->SetBounds(0, 0, 1000, 1000);
- styled()->Layout();
+ Link* link = new Link(ASCIIToUTF16(text_link));
+ container->AddChildView(link);
+ const SkColor kDefaultLinkColor = link->enabled_color();
EXPECT_EQ(SK_ColorRED,
static_cast<Label*>(styled()->child_at(0))->enabled_color());
@@ -309,23 +320,18 @@ TEST_F(StyledLabelTest, Color) {
static_cast<Label*>(styled()->child_at(1))->enabled_color());
EXPECT_EQ(kDefaultTextColor,
static_cast<Label*>(styled()->child_at(2))->enabled_color());
-}
-TEST_F(StyledLabelTest, ColorReadability) {
- const std::string text(
- "This is a block of text that needs color adjustment.");
- InitStyledLabel(text);
+ // Test adjusted color readability.
styled()->SetDisplayedOnBackgroundColor(SK_ColorBLACK);
-
- // Obtain the text color if it were a pure label.
- Label label(ASCIIToUTF16(text));
- label.SetBackgroundColor(SK_ColorBLACK);
-
- styled()->SetBounds(0, 0, 1000, 1000);
styled()->Layout();
+ label->SetBackgroundColor(SK_ColorBLACK);
- EXPECT_EQ(label.enabled_color(),
- static_cast<Label*>(styled()->child_at(0))->enabled_color());
+ const SkColor kAdjustedTextColor = label->enabled_color();
+ EXPECT_NE(kAdjustedTextColor, kDefaultTextColor);
+ EXPECT_EQ(kAdjustedTextColor,
+ static_cast<Label*>(styled()->child_at(2))->enabled_color());
+
+ widget->CloseNow();
}
TEST_F(StyledLabelTest, StyledRangeWithTooltip) {
@@ -406,4 +412,4 @@ TEST_F(StyledLabelTest, HandleEmptyLayout) {
EXPECT_EQ(0, styled()->child_count());
}
-} // namespace
+} // namespace views
« no previous file with comments | « ui/views/controls/scroll_view.cc ('k') | ui/views/controls/textfield/textfield.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698