| 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/views/controls/textfield/native_textfield_views.h" | 5 #include "ui/views/controls/textfield/native_textfield_views.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "url/gurl.h" | 40 #include "url/gurl.h" |
| 41 | 41 |
| 42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 43 #include "base/win/windows_version.h" | 43 #include "base/win/windows_version.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 #define EXPECT_STR_EQ(ascii, utf16) EXPECT_EQ(ASCIIToUTF16(ascii), utf16) | 46 #define EXPECT_STR_EQ(ascii, utf16) EXPECT_EQ(ASCIIToUTF16(ascii), utf16) |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 const char16 kHebrewLetterSamekh = 0x05E1; | 50 const base::char16 kHebrewLetterSamekh = 0x05E1; |
| 51 | 51 |
| 52 // A Textfield wrapper to intercept OnKey[Pressed|Released]() ressults. | 52 // A Textfield wrapper to intercept OnKey[Pressed|Released]() ressults. |
| 53 class TestTextfield : public views::Textfield { | 53 class TestTextfield : public views::Textfield { |
| 54 public: | 54 public: |
| 55 explicit TestTextfield(StyleFlags style) | 55 explicit TestTextfield(StyleFlags style) |
| 56 : Textfield(style), | 56 : Textfield(style), |
| 57 key_handled_(false), | 57 key_handled_(false), |
| 58 key_received_(false) { | 58 key_received_(false) { |
| 59 } | 59 } |
| 60 | 60 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 225 } |
| 226 | 226 |
| 227 void SendKeyEvent(ui::KeyboardCode key_code, bool shift, bool control) { | 227 void SendKeyEvent(ui::KeyboardCode key_code, bool shift, bool control) { |
| 228 SendKeyEvent(key_code, false, shift, control, false); | 228 SendKeyEvent(key_code, false, shift, control, false); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void SendKeyEvent(ui::KeyboardCode key_code) { | 231 void SendKeyEvent(ui::KeyboardCode key_code) { |
| 232 SendKeyEvent(key_code, false, false); | 232 SendKeyEvent(key_code, false, false); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void SendKeyEvent(char16 ch) { | 235 void SendKeyEvent(base::char16 ch) { |
| 236 if (ch < 0x80) { | 236 if (ch < 0x80) { |
| 237 ui::KeyboardCode code = | 237 ui::KeyboardCode code = |
| 238 ch == ' ' ? ui::VKEY_SPACE : | 238 ch == ' ' ? ui::VKEY_SPACE : |
| 239 static_cast<ui::KeyboardCode>(ui::VKEY_A + ch - 'a'); | 239 static_cast<ui::KeyboardCode>(ui::VKEY_A + ch - 'a'); |
| 240 SendKeyEvent(code); | 240 SendKeyEvent(code); |
| 241 } else { | 241 } else { |
| 242 ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0, false); | 242 ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0, false); |
| 243 event.set_character(ch); | 243 event.set_character(ch); |
| 244 input_method_->DispatchKeyEvent(event); | 244 input_method_->DispatchKeyEvent(event); |
| 245 } | 245 } |
| (...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 | 1797 |
| 1798 // Return false if the index is out of range. | 1798 // Return false if the index is out of range. |
| 1799 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count, &rect)); | 1799 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count, &rect)); |
| 1800 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count + 1, &rect)); | 1800 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count + 1, &rect)); |
| 1801 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count + 100, &rect)); | 1801 EXPECT_FALSE(client->GetCompositionCharacterBounds(char_count + 100, &rect)); |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 TEST_F(NativeTextfieldViewsTest, GetCompositionCharacterBounds_ComplexText) { | 1804 TEST_F(NativeTextfieldViewsTest, GetCompositionCharacterBounds_ComplexText) { |
| 1805 InitTextfield(Textfield::STYLE_DEFAULT); | 1805 InitTextfield(Textfield::STYLE_DEFAULT); |
| 1806 | 1806 |
| 1807 const char16 kUtf16Chars[] = { | 1807 const base::char16 kUtf16Chars[] = { |
| 1808 // U+0020 SPACE | 1808 // U+0020 SPACE |
| 1809 0x0020, | 1809 0x0020, |
| 1810 // U+1F408 (CAT) as surrogate pair | 1810 // U+1F408 (CAT) as surrogate pair |
| 1811 0xd83d, 0xdc08, | 1811 0xd83d, 0xdc08, |
| 1812 // U+5642 as Ideographic Variation Sequences | 1812 // U+5642 as Ideographic Variation Sequences |
| 1813 0x5642, 0xDB40, 0xDD00, | 1813 0x5642, 0xDB40, 0xDD00, |
| 1814 // U+260E (BLACK TELEPHONE) as Emoji Variation Sequences | 1814 // U+260E (BLACK TELEPHONE) as Emoji Variation Sequences |
| 1815 0x260E, 0xFE0F, | 1815 0x260E, 0xFE0F, |
| 1816 // U+0020 SPACE | 1816 // U+0020 SPACE |
| 1817 0x0020, | 1817 0x0020, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 // Set text which may fall back to a font which has taller baseline than | 1987 // Set text which may fall back to a font which has taller baseline than |
| 1988 // the default font. | 1988 // the default font. |
| 1989 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91")); | 1989 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91")); |
| 1990 const int new_baseline = textfield_->GetBaseline(); | 1990 const int new_baseline = textfield_->GetBaseline(); |
| 1991 | 1991 |
| 1992 // Regardless of the text, the baseline must be the same. | 1992 // Regardless of the text, the baseline must be the same. |
| 1993 EXPECT_EQ(new_baseline, old_baseline); | 1993 EXPECT_EQ(new_baseline, old_baseline); |
| 1994 } | 1994 } |
| 1995 | 1995 |
| 1996 } // namespace views | 1996 } // namespace views |
| OLD | NEW |