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

Side by Side Diff: ui/gfx/render_text_unittest.cc

Issue 10591003: Expose GetBaseline() method on RenderText. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 const int height1 = render_text->GetStringSize().height(); 1010 const int height1 = render_text->GetStringSize().height();
1011 EXPECT_GT(height1, 0); 1011 EXPECT_GT(height1, 0);
1012 1012
1013 // Check that setting the larger font increases the height. 1013 // Check that setting the larger font increases the height.
1014 render_text->SetFontList(FontList(larger_font)); 1014 render_text->SetFontList(FontList(larger_font));
1015 const int height2 = render_text->GetStringSize().height(); 1015 const int height2 = render_text->GetStringSize().height();
1016 EXPECT_GT(height2, height1); 1016 EXPECT_GT(height2, height1);
1017 } 1017 }
1018 } 1018 }
1019 1019
1020 TEST_F(RenderTextTest, GetBaselineSanity) {
1021 scoped_ptr<RenderText> render_text(RenderText::CreateRenderText());
1022 render_text->SetText(UTF8ToUTF16("Hello World"));
1023 const int baseline = render_text->GetBaseline();
1024 EXPECT_GT(baseline, 0);
1025 }
1026
1020 TEST_F(RenderTextTest, CursorBoundsInReplacementMode) { 1027 TEST_F(RenderTextTest, CursorBoundsInReplacementMode) {
1021 scoped_ptr<RenderText> render_text(RenderText::CreateRenderText()); 1028 scoped_ptr<RenderText> render_text(RenderText::CreateRenderText());
1022 render_text->SetText(ASCIIToUTF16("abcdefg")); 1029 render_text->SetText(ASCIIToUTF16("abcdefg"));
1023 render_text->SetDisplayRect(Rect(100, 17)); 1030 render_text->SetDisplayRect(Rect(100, 17));
1024 SelectionModel sel_b(1, CURSOR_FORWARD); 1031 SelectionModel sel_b(1, CURSOR_FORWARD);
1025 SelectionModel sel_c(2, CURSOR_FORWARD); 1032 SelectionModel sel_c(2, CURSOR_FORWARD);
1026 Rect cursor_around_b = render_text->GetCursorBounds(sel_b, false); 1033 Rect cursor_around_b = render_text->GetCursorBounds(sel_b, false);
1027 Rect cursor_before_b = render_text->GetCursorBounds(sel_b, true); 1034 Rect cursor_before_b = render_text->GetCursorBounds(sel_b, true);
1028 Rect cursor_before_c = render_text->GetCursorBounds(sel_c, true); 1035 Rect cursor_before_c = render_text->GetCursorBounds(sel_c, true);
1029 EXPECT_EQ(cursor_around_b.x(), cursor_before_b.x()); 1036 EXPECT_EQ(cursor_around_b.x(), cursor_before_b.x());
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 render_text->SetDisplayRect(Rect(width + 10, 1)); 1243 render_text->SetDisplayRect(Rect(width + 10, 1));
1237 EXPECT_EQ(render_text->display_rect().width() - width - 1, 1244 EXPECT_EQ(render_text->display_rect().width() - width - 1,
1238 render_text->GetUpdatedCursorBounds().x()); 1245 render_text->GetUpdatedCursorBounds().x());
1239 1246
1240 // Reset locale. 1247 // Reset locale.
1241 base::i18n::SetICUDefaultLocale(locale); 1248 base::i18n::SetICUDefaultLocale(locale);
1242 } 1249 }
1243 #endif // !defined(OS_LINUX) || defined(OS_CHROMEOS) 1250 #endif // !defined(OS_LINUX) || defined(OS_CHROMEOS)
1244 1251
1245 } // namespace gfx 1252 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698