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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 EXPECT_EQ(0, render_text->GetStringSize().width()); | 1121 EXPECT_EQ(0, render_text->GetStringSize().width()); |
1122 | 1122 |
1123 render_text->SetText(UTF8ToUTF16(" ")); | 1123 render_text->SetText(UTF8ToUTF16(" ")); |
1124 EXPECT_EQ(font.GetHeight(), render_text->GetStringSize().height()); | 1124 EXPECT_EQ(font.GetHeight(), render_text->GetStringSize().height()); |
1125 } | 1125 } |
1126 #endif // !defined(OS_MACOSX) | 1126 #endif // !defined(OS_MACOSX) |
1127 | 1127 |
1128 TEST_F(RenderTextTest, SetFont) { | 1128 TEST_F(RenderTextTest, SetFont) { |
1129 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 1129 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
1130 render_text->SetFont(Font("Arial", 12)); | 1130 render_text->SetFont(Font("Arial", 12)); |
1131 EXPECT_EQ("Arial", render_text->GetFont().GetFontName()); | 1131 EXPECT_EQ("Arial", render_text->GetPrimaryFont().GetFontName()); |
1132 EXPECT_EQ(12, render_text->GetFont().GetFontSize()); | 1132 EXPECT_EQ(12, render_text->GetPrimaryFont().GetFontSize()); |
1133 } | 1133 } |
1134 | 1134 |
1135 TEST_F(RenderTextTest, StringSizeBoldWidth) { | 1135 TEST_F(RenderTextTest, StringSizeBoldWidth) { |
1136 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 1136 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
1137 render_text->SetText(UTF8ToUTF16("Hello World")); | 1137 render_text->SetText(UTF8ToUTF16("Hello World")); |
1138 | 1138 |
1139 const int plain_width = render_text->GetStringSize().width(); | 1139 const int plain_width = render_text->GetStringSize().width(); |
1140 EXPECT_GT(plain_width, 0); | 1140 EXPECT_GT(plain_width, 0); |
1141 | 1141 |
1142 // Apply a bold style and check that the new width is greater. | 1142 // Apply a bold style and check that the new width is greater. |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 EXPECT_EQ(render_text->display_rect().width() - width - 1, | 1509 EXPECT_EQ(render_text->display_rect().width() - width - 1, |
1510 render_text->GetUpdatedCursorBounds().x()); | 1510 render_text->GetUpdatedCursorBounds().x()); |
1511 | 1511 |
1512 // Reset the application default text direction to LTR. | 1512 // Reset the application default text direction to LTR. |
1513 SetRTL(was_rtl); | 1513 SetRTL(was_rtl); |
1514 EXPECT_EQ(was_rtl, base::i18n::IsRTL()); | 1514 EXPECT_EQ(was_rtl, base::i18n::IsRTL()); |
1515 } | 1515 } |
1516 #endif // !defined(OS_MACOSX) | 1516 #endif // !defined(OS_MACOSX) |
1517 | 1517 |
1518 } // namespace gfx | 1518 } // namespace gfx |
OLD | NEW |