summaryrefslogtreecommitdiffstats
path: root/ui/views/touchui/touch_selection_controller_impl_unittest.cc
diff options
context:
space:
mode:
authoryukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 17:01:50 +0000
committeryukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 17:01:50 +0000
commit7682076160467ecef5f3e788006036f834df5b7d (patch)
tree30511a8e648f475ff1e6258b735872004d84c91b /ui/views/touchui/touch_selection_controller_impl_unittest.cc
parent2a684221ee7fe5a83b0c51e87424ad9f3828b2bc (diff)
downloadchromium_src-7682076160467ecef5f3e788006036f834df5b7d.zip
chromium_src-7682076160467ecef5f3e788006036f834df5b7d.tar.gz
chromium_src-7682076160467ecef5f3e788006036f834df5b7d.tar.bz2
Supports FontList in Textfield.
The current interface of Textfield does not support FontList while RenderText supports FontList. This CL supports FontList in Textfield. The direct cause of crbug.com/263169 was that RenderText always uses the IDS_UI_FONT_FAMILY_CROS font set ignoring what font is specified for Textfield on ChromeOS. (See https://code.google.com/p/chromium/codesearch#chromium/src/ui/views/controls/textfield/native_textfield_views.cc&q=IDS_UI_FONT_FAMILY_CROS&sq=package:chromium&type=cs&l=88 ) The Omnibox font size is carefully calculated, but the font is ignored right now. This CL changes the following: - Supports FontList in Textfield so Omnibox layer can specify the font set, such as IDS_UI_FONT_FAMILY_CROS, for the underlying Textfield. - Makes NativeTextfieldViews follow the specified font set via Textfield on ChromeOS. BUG=263169,263196 TEST=Test manually. Review URL: https://chromiumcodereview.appspot.com/19666006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215055 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/touchui/touch_selection_controller_impl_unittest.cc')
-rw-r--r--ui/views/touchui/touch_selection_controller_impl_unittest.cc32
1 files changed, 17 insertions, 15 deletions
diff --git a/ui/views/touchui/touch_selection_controller_impl_unittest.cc b/ui/views/touchui/touch_selection_controller_impl_unittest.cc
index 9177099..2925046 100644
--- a/ui/views/touchui/touch_selection_controller_impl_unittest.cc
+++ b/ui/views/touchui/touch_selection_controller_impl_unittest.cc
@@ -284,7 +284,8 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectCallbackTest) {
VERIFY_HANDLE_POSITIONS(false);
// Drag selection handle 2 to right by 3 chars.
- int x = textfield_->font().GetStringWidth(ASCIIToUTF16("ld "));
+ const gfx::Font& font = textfield_->GetPrimaryFont();
+ int x = font.GetStringWidth(ASCIIToUTF16("ld "));
SimulateSelectionHandleDrag(gfx::Point(x, 0), 2);
EXPECT_EQ(UTF16ToUTF8(textfield_->GetSelectedText()), "tfield ");
VERIFY_HANDLE_POSITIONS(false);
@@ -296,13 +297,13 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectCallbackTest) {
VERIFY_HANDLE_POSITIONS(true);
// Drag selection handle 1 across selection handle 2.
- x = textfield_->font().GetStringWidth(ASCIIToUTF16("textfield with "));
+ x = font.GetStringWidth(ASCIIToUTF16("textfield with "));
SimulateSelectionHandleDrag(gfx::Point(x, 0), 1);
EXPECT_EQ(UTF16ToUTF8(textfield_->GetSelectedText()), "with ");
VERIFY_HANDLE_POSITIONS(true);
// Drag selection handle 2 across selection handle 1.
- x = textfield_->font().GetStringWidth(ASCIIToUTF16("with selected "));
+ x = font.GetStringWidth(ASCIIToUTF16("with selected "));
SimulateSelectionHandleDrag(gfx::Point(x, 0), 2);
EXPECT_EQ(UTF16ToUTF8(textfield_->GetSelectedText()), "selected ");
VERIFY_HANDLE_POSITIONS(false);
@@ -322,13 +323,14 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) {
VERIFY_HANDLE_POSITIONS(false);
// Drag selection handle 2 to right by 1 char.
- int x = textfield_->font().GetStringWidth(WideToUTF16(L"\x05e3"));
+ const gfx::Font& font = textfield_->GetPrimaryFont();
+ int x = font.GetStringWidth(WideToUTF16(L"\x05e3"));
SimulateSelectionHandleDrag(gfx::Point(x, 0), 2);
EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(false);
// Drag selection handle 1 to left by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"b"));
+ x = font.GetStringWidth(WideToUTF16(L"b"));
SimulateSelectionHandleDrag(gfx::Point(-x, 0), 1);
EXPECT_EQ(WideToUTF16(L"bc\x05e1\x05e2"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(true);
@@ -339,13 +341,13 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) {
VERIFY_HANDLE_POSITIONS(false);
// Drag selection handle 1 to right by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"\x05e3"));
+ x = font.GetStringWidth(WideToUTF16(L"\x05e3"));
SimulateSelectionHandleDrag(gfx::Point(x, 0), 1);
EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(true);
// Drag selection handle 2 to left by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"b"));
+ x = font.GetStringWidth(WideToUTF16(L"b"));
SimulateSelectionHandleDrag(gfx::Point(-x, 0), 2);
EXPECT_EQ(WideToUTF16(L"bc\x05e1\x05e2"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(false);
@@ -364,14 +366,14 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) {
Need further investigation on whether this is a bug in Pango and how to
work around it.
// Drag selection handle 2 to left by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"\x05e2"));
+ x = font.GetStringWidth(WideToUTF16(L"\x05e2"));
SimulateSelectionHandleDrag(gfx::Point(-x, 0), 2);
EXPECT_EQ(WideToUTF16(L"\x05e1\x05e2"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(false);
*/
// Drag selection handle 1 to right by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"d"));
+ x = font.GetStringWidth(WideToUTF16(L"d"));
SimulateSelectionHandleDrag(gfx::Point(x, 0), 1);
EXPECT_EQ(WideToUTF16(L"\x05e2\x05e3" L"d"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(true);
@@ -383,14 +385,14 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) {
/* TODO(xji): see detail of above commented out test case.
// Drag selection handle 1 to left by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"\x05e2"));
+ x = font.GetStringWidth(WideToUTF16(L"\x05e2"));
SimulateSelectionHandleDrag(gfx::Point(-x, 0), 1);
EXPECT_EQ(WideToUTF16(L"\x05e1\x05e2"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(true);
*/
// Drag selection handle 2 to right by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"d"));
+ x = font.GetStringWidth(WideToUTF16(L"d"));
SimulateSelectionHandleDrag(gfx::Point(x, 0), 2);
EXPECT_EQ(WideToUTF16(L"\x05e2\x05e3" L"d"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(false);
@@ -401,13 +403,13 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) {
VERIFY_HANDLE_POSITIONS(false);
// Drag selection handle 2 to left by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"c"));
+ x = font.GetStringWidth(WideToUTF16(L"c"));
SimulateSelectionHandleDrag(gfx::Point(-x, 0), 2);
EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(false);
// Drag selection handle 1 to right by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"\x05e2"));
+ x = font.GetStringWidth(WideToUTF16(L"\x05e2"));
SimulateSelectionHandleDrag(gfx::Point(x, 0), 1);
EXPECT_EQ(WideToUTF16(L"c\x05e1"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(true);
@@ -418,13 +420,13 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) {
VERIFY_HANDLE_POSITIONS(false);
// Drag selection handle 1 to left by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"c"));
+ x = font.GetStringWidth(WideToUTF16(L"c"));
SimulateSelectionHandleDrag(gfx::Point(-x, 0), 1);
EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(true);
// Drag selection handle 2 to right by 1 char.
- x = textfield_->font().GetStringWidth(WideToUTF16(L"\x05e2"));
+ x = font.GetStringWidth(WideToUTF16(L"\x05e2"));
SimulateSelectionHandleDrag(gfx::Point(x, 0), 2);
EXPECT_EQ(WideToUTF16(L"c\x05e1"), textfield_->GetSelectedText());
VERIFY_HANDLE_POSITIONS(false);