summaryrefslogtreecommitdiffstats
path: root/ui/gfx/render_text_unittest.cc
diff options
context:
space:
mode:
authorasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 18:54:20 +0000
committerasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 18:54:20 +0000
commitf602f572e53d7b0152a0faf23c16aab7da70740b (patch)
tree870f2009d04c010bc5badba24479702075edb865 /ui/gfx/render_text_unittest.cc
parent9f107bd98fe6283d7e726817b89286cab726c8a6 (diff)
downloadchromium_src-f602f572e53d7b0152a0faf23c16aab7da70740b.zip
chromium_src-f602f572e53d7b0152a0faf23c16aab7da70740b.tar.gz
chromium_src-f602f572e53d7b0152a0faf23c16aab7da70740b.tar.bz2
Expand RenderText bold width test.
Also, add some ASSERTS() to a couple of other tests. BUG=105550 TEST=This is one. Review URL: https://chromiumcodereview.appspot.com/10382103 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136354 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/render_text_unittest.cc')
-rw-r--r--ui/gfx/render_text_unittest.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index 5769fe1..607869c 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -943,12 +943,22 @@ TEST_F(RenderTextTest, StringSizeBoldWidth) {
// Apply a bold style and check that the new width is greater.
StyleRange bold;
- bold.font_style |= gfx::Font::BOLD;
+ bold.font_style |= Font::BOLD;
render_text->set_default_style(bold);
render_text->ApplyDefaultStyle();
const int bold_width = render_text->GetStringSize().width();
EXPECT_GT(bold_width, plain_width);
+
+ // Now, apply a plain style over the first word only.
+ StyleRange plain;
+ plain.font_style = Font::NORMAL;
+ plain.range = ui::Range(0, 5);
+ render_text->ApplyStyleRange(plain);
+
+ const int plain_bold_width = render_text->GetStringSize().width();
+ EXPECT_GT(plain_bold_width, plain_width);
+ EXPECT_LT(plain_bold_width, bold_width);
}
TEST_F(RenderTextTest, StringSizeHeight) {
@@ -1022,6 +1032,7 @@ TEST_F(RenderTextTest, DisplayRectShowsCursorLTR) {
render_text->MoveCursorTo(SelectionModel(render_text->text().length(),
CURSOR_FORWARD));
int width = render_text->GetStringSize().width();
+ ASSERT_GT(width, 10);
// Ensure that the cursor is placed at the width of its preceding text.
render_text->SetDisplayRect(Rect(width + 10, 1));
@@ -1046,6 +1057,7 @@ TEST_F(RenderTextTest, DisplayRectShowsCursorLTR) {
L"\x5d8\x5d9\x5da\x5db\x5dc\x5dd\x5de\x5df"));
render_text->MoveCursorTo(SelectionModel(0, CURSOR_FORWARD));
width = render_text->GetStringSize().width();
+ ASSERT_GT(width, 10);
// Ensure that the cursor is placed at the width of its preceding text.
render_text->SetDisplayRect(Rect(width + 10, 1));
@@ -1075,6 +1087,7 @@ TEST_F(RenderTextTest, DisplayRectShowsCursorRTL) {
render_text->SetText(WideToUTF16(L"abcdefghijklmnopqrstuvwxzyabcdefg"));
render_text->MoveCursorTo(SelectionModel(0, CURSOR_FORWARD));
int width = render_text->GetStringSize().width();
+ ASSERT_GT(width, 10);
// Ensure that the cursor is placed at the width of its preceding text.
render_text->SetDisplayRect(Rect(width + 10, 1));
@@ -1100,6 +1113,7 @@ TEST_F(RenderTextTest, DisplayRectShowsCursorRTL) {
render_text->MoveCursorTo(SelectionModel(render_text->text().length(),
CURSOR_FORWARD));
width = render_text->GetStringSize().width();
+ ASSERT_GT(width, 10);
// Ensure that the cursor is placed at the width of its preceding text.
render_text->SetDisplayRect(Rect(width + 10, 1));