| Index: ui/gfx/render_text_unittest.cc
|
| diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
|
| index d07c8f5393b9ded8a8ae35a422a432d6b210c901..93bd8995a198682cc93dcb4f56c75faf958988ec 100644
|
| --- a/ui/gfx/render_text_unittest.cc
|
| +++ b/ui/gfx/render_text_unittest.cc
|
| @@ -261,13 +261,14 @@ TEST_F(RenderTextTest, SetStyles) {
|
| const SkColor color = SK_ColorRED;
|
| render_text->SetColor(color);
|
| render_text->SetBaselineStyle(SUPERSCRIPT);
|
| - render_text->SetStyle(BOLD, true);
|
| + render_text->SetWeight(gfx::Font::Weight::BOLD);
|
| render_text->SetStyle(UNDERLINE, false);
|
| const wchar_t* const cases[] = { kWeak, kLtr, L"Hello", kRtl, L"", L"" };
|
| for (size_t i = 0; i < arraysize(cases); ++i) {
|
| EXPECT_TRUE(render_text->colors().EqualsValueForTesting(color));
|
| EXPECT_TRUE(render_text->baselines().EqualsValueForTesting(SUPERSCRIPT));
|
| - EXPECT_TRUE(render_text->styles()[BOLD].EqualsValueForTesting(true));
|
| + EXPECT_TRUE(
|
| + render_text->weights().EqualsValueForTesting(gfx::Font::Weight::BOLD));
|
| EXPECT_TRUE(render_text->styles()[UNDERLINE].EqualsValueForTesting(false));
|
| render_text->SetText(WideToUTF16(cases[i]));
|
|
|
| @@ -286,7 +287,7 @@ TEST_F(RenderTextTest, ApplyStyles) {
|
| // Apply a ranged color and style and check the resulting breaks.
|
| render_text->ApplyColor(SK_ColorRED, Range(1, 4));
|
| render_text->ApplyBaselineStyle(SUPERIOR, Range(2, 4));
|
| - render_text->ApplyStyle(BOLD, true, Range(2, 5));
|
| + render_text->ApplyWeight(gfx::Font::Weight::BOLD, Range(2, 5));
|
| std::vector<std::pair<size_t, SkColor> > expected_color;
|
| expected_color.push_back(std::pair<size_t, SkColor>(0, SK_ColorBLACK));
|
| expected_color.push_back(std::pair<size_t, SkColor>(1, SK_ColorRED));
|
| @@ -301,26 +302,30 @@ TEST_F(RenderTextTest, ApplyStyles) {
|
| std::pair<size_t, BaselineStyle>(4, NORMAL_BASELINE));
|
| EXPECT_TRUE(
|
| render_text->baselines().EqualsForTesting(expected_baseline_style));
|
| - std::vector<std::pair<size_t, bool> > expected_style;
|
| - expected_style.push_back(std::pair<size_t, bool>(0, false));
|
| - expected_style.push_back(std::pair<size_t, bool>(2, true));
|
| - expected_style.push_back(std::pair<size_t, bool>(5, false));
|
| - EXPECT_TRUE(render_text->styles()[BOLD].EqualsForTesting(expected_style));
|
| + std::vector<std::pair<size_t, gfx::Font::Weight>> expected_weight;
|
| + expected_weight.push_back(
|
| + std::pair<size_t, gfx::Font::Weight>(0, gfx::Font::Weight::NORMAL));
|
| + expected_weight.push_back(
|
| + std::pair<size_t, gfx::Font::Weight>(2, gfx::Font::Weight::BOLD));
|
| + expected_weight.push_back(
|
| + std::pair<size_t, gfx::Font::Weight>(5, gfx::Font::Weight::NORMAL));
|
| + EXPECT_TRUE(render_text->weights().EqualsForTesting(expected_weight));
|
|
|
| // Ensure that setting a value overrides the ranged values.
|
| render_text->SetColor(SK_ColorBLUE);
|
| EXPECT_TRUE(render_text->colors().EqualsValueForTesting(SK_ColorBLUE));
|
| render_text->SetBaselineStyle(SUBSCRIPT);
|
| EXPECT_TRUE(render_text->baselines().EqualsValueForTesting(SUBSCRIPT));
|
| - render_text->SetStyle(BOLD, false);
|
| - EXPECT_TRUE(render_text->styles()[BOLD].EqualsValueForTesting(false));
|
| + render_text->SetWeight(gfx::Font::Weight::NORMAL);
|
| + EXPECT_TRUE(
|
| + render_text->weights().EqualsValueForTesting(gfx::Font::Weight::NORMAL));
|
|
|
| // Apply a value over the text end and check the resulting breaks (INT_MAX
|
| // should be used instead of the text length for the range end)
|
| const size_t text_length = render_text->text().length();
|
| render_text->ApplyColor(SK_ColorRED, Range(0, text_length));
|
| render_text->ApplyBaselineStyle(SUPERIOR, Range(0, text_length));
|
| - render_text->ApplyStyle(BOLD, true, Range(2, text_length));
|
| + render_text->ApplyWeight(gfx::Font::Weight::BOLD, Range(2, text_length));
|
| std::vector<std::pair<size_t, SkColor> > expected_color_end;
|
| expected_color_end.push_back(std::pair<size_t, SkColor>(0, SK_ColorRED));
|
| EXPECT_TRUE(render_text->colors().EqualsForTesting(expected_color_end));
|
| @@ -328,10 +333,12 @@ TEST_F(RenderTextTest, ApplyStyles) {
|
| expected_baseline_end.push_back(
|
| std::pair<size_t, BaselineStyle>(0, SUPERIOR));
|
| EXPECT_TRUE(render_text->baselines().EqualsForTesting(expected_baseline_end));
|
| - std::vector<std::pair<size_t, bool> > expected_style_end;
|
| - expected_style_end.push_back(std::pair<size_t, bool>(0, false));
|
| - expected_style_end.push_back(std::pair<size_t, bool>(2, true));
|
| - EXPECT_TRUE(render_text->styles()[BOLD].EqualsForTesting(expected_style_end));
|
| + std::vector<std::pair<size_t, gfx::Font::Weight>> expected_weight_end;
|
| + expected_weight_end.push_back(
|
| + std::pair<size_t, gfx::Font::Weight>(0, gfx::Font::Weight::NORMAL));
|
| + expected_weight_end.push_back(
|
| + std::pair<size_t, gfx::Font::Weight>(2, gfx::Font::Weight::BOLD));
|
| + EXPECT_TRUE(render_text->weights().EqualsForTesting(expected_weight_end));
|
|
|
| // Ensure ranged values adjust to accommodate text length changes.
|
| render_text->ApplyStyle(ITALIC, true, Range(0, 2));
|
| @@ -1622,12 +1629,12 @@ TEST_F(RenderTextTest, StringSizeBoldWidth) {
|
| EXPECT_GT(plain_width, 0);
|
|
|
| // Apply a bold style and check that the new width is greater.
|
| - render_text->SetStyle(BOLD, true);
|
| + render_text->SetWeight(gfx::Font::Weight::BOLD);
|
| const int bold_width = render_text->GetStringSize().width();
|
| EXPECT_GT(bold_width, plain_width);
|
|
|
| // Now, apply a plain style over the first word only.
|
| - render_text->ApplyStyle(BOLD, false, Range(0, 5));
|
| + render_text->ApplyWeight(gfx::Font::Weight::NORMAL, Range(0, 5));
|
| const int plain_bold_width = render_text->GetStringSize().width();
|
| EXPECT_GT(plain_bold_width, plain_width);
|
| EXPECT_LT(plain_bold_width, bold_width);
|
| @@ -2924,7 +2931,7 @@ TEST_F(RenderTextTest, StringFitsOwnWidth) {
|
| const base::string16 kString = ASCIIToUTF16("www.example.com");
|
|
|
| render_text->SetText(kString);
|
| - render_text->ApplyStyle(BOLD, true, Range(0, 3));
|
| + render_text->ApplyWeight(gfx::Font::Weight::BOLD, Range(0, 3));
|
| render_text->SetElideBehavior(ELIDE_TAIL);
|
|
|
| render_text->SetDisplayRect(Rect(0, 0, 500, 100));
|
| @@ -3032,7 +3039,7 @@ TEST_F(RenderTextTest, TextDoesntClip) {
|
| render_text->ApplyBaselineStyle(SUPERIOR, Range(3, 4));
|
| render_text->ApplyBaselineStyle(INFERIOR, Range(5, 6));
|
| render_text->ApplyBaselineStyle(SUBSCRIPT, Range(7, 8));
|
| - render_text->SetStyle(BOLD, true);
|
| + render_text->SetWeight(gfx::Font::Weight::BOLD);
|
| render_text->SetDisplayRect(
|
| Rect(kTestSize, kTestSize, string_size.width(), string_size.height()));
|
| // Allow the RenderText to paint outside of its display rect.
|
|
|