| OLD | NEW |
| 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/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/gfx/break_list.h" | 14 #include "ui/gfx/break_list.h" |
| 15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 16 | 16 |
| 17 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 18 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
| 19 #include "ui/gfx/render_text_win.h" | 19 #include "ui/gfx/render_text_win.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #if defined(OS_LINUX) | 22 #if defined(OS_LINUX) && !defined(USE_OZONE) |
| 23 #include "ui/gfx/render_text_linux.h" | 23 #include "ui/gfx/render_text_pango.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 #if defined(TOOLKIT_GTK) | 26 #if defined(TOOLKIT_GTK) |
| 27 #include <gtk/gtk.h> | 27 #include <gtk/gtk.h> |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 namespace gfx { | 30 namespace gfx { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic)); | 177 EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic)); |
| 178 render_text->SetText(ASCIIToUTF16("01234")); | 178 render_text->SetText(ASCIIToUTF16("01234")); |
| 179 expected_italic.resize(3); | 179 expected_italic.resize(3); |
| 180 EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic)); | 180 EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic)); |
| 181 | 181 |
| 182 // Appending text should extend the terminal styles without changing breaks. | 182 // Appending text should extend the terminal styles without changing breaks. |
| 183 render_text->SetText(ASCIIToUTF16("012345678")); | 183 render_text->SetText(ASCIIToUTF16("012345678")); |
| 184 EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic)); | 184 EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic)); |
| 185 } | 185 } |
| 186 | 186 |
| 187 #if defined(OS_LINUX) | 187 #if defined(OS_LINUX) && !defined(USE_OZONE) |
| 188 TEST_F(RenderTextTest, PangoAttributes) { | 188 TEST_F(RenderTextTest, PangoAttributes) { |
| 189 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 189 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
| 190 render_text->SetText(ASCIIToUTF16("012345678")); | 190 render_text->SetText(ASCIIToUTF16("012345678")); |
| 191 | 191 |
| 192 // Apply ranged BOLD/ITALIC styles and check the resulting Pango attributes. | 192 // Apply ranged BOLD/ITALIC styles and check the resulting Pango attributes. |
| 193 render_text->ApplyStyle(BOLD, true, Range(2, 4)); | 193 render_text->ApplyStyle(BOLD, true, Range(2, 4)); |
| 194 render_text->ApplyStyle(ITALIC, true, Range(1, 3)); | 194 render_text->ApplyStyle(ITALIC, true, Range(1, 3)); |
| 195 | 195 |
| 196 struct { | 196 struct { |
| 197 int start; | 197 int start; |
| (...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 render_text->SetText(WideToUTF16(L"x \x25B6 y")); | 1744 render_text->SetText(WideToUTF16(L"x \x25B6 y")); |
| 1745 render_text->EnsureLayout(); | 1745 render_text->EnsureLayout(); |
| 1746 ASSERT_EQ(3U, render_text->runs_.size()); | 1746 ASSERT_EQ(3U, render_text->runs_.size()); |
| 1747 EXPECT_EQ(Range(0, 2), render_text->runs_[0]->range); | 1747 EXPECT_EQ(Range(0, 2), render_text->runs_[0]->range); |
| 1748 EXPECT_EQ(Range(2, 3), render_text->runs_[1]->range); | 1748 EXPECT_EQ(Range(2, 3), render_text->runs_[1]->range); |
| 1749 EXPECT_EQ(Range(3, 5), render_text->runs_[2]->range); | 1749 EXPECT_EQ(Range(3, 5), render_text->runs_[2]->range); |
| 1750 } | 1750 } |
| 1751 #endif // defined(OS_WIN) | 1751 #endif // defined(OS_WIN) |
| 1752 | 1752 |
| 1753 } // namespace gfx | 1753 } // namespace gfx |
| OLD | NEW |