| Index: chrome/renderer/spellchecker/spellcheck_worditerator_unittest.cc
|
| ===================================================================
|
| --- chrome/renderer/spellchecker/spellcheck_worditerator_unittest.cc (revision 154314)
|
| +++ chrome/renderer/spellchecker/spellcheck_worditerator_unittest.cc (working copy)
|
| @@ -164,3 +164,67 @@
|
| EXPECT_EQ(0, actual_start);
|
| EXPECT_EQ(0, actual_end);
|
| }
|
| +
|
| +// Vertify our SpellcheckWordIterator can treat ASCII numbers as word characters
|
| +// on LTR languages. On the other hand, it should not treat ASCII numbers as
|
| +// word characters on RTL languages because they change the text direction from
|
| +// RTL to LTR.
|
| +TEST(SpellcheckWordIteratorTest, TreatNumbersAsWordCharacters) {
|
| + // A set of a language, a dummy word, and a text direction used in this test.
|
| + // For each language, this test splits a dummy word, which consists of ASCII
|
| + // numbers and an alphabet of the language, into words. When ASCII numbers are
|
| + // treated as word characters, the split word becomes equal to the dummy word.
|
| + // Otherwise, the split word does not include ASCII numbers.
|
| + static const struct {
|
| + const char* language;
|
| + const wchar_t* text;
|
| + bool left_to_right;
|
| + } kTestCases[] = {
|
| + {
|
| + // English
|
| + "en-US", L"0123456789" L"a", true,
|
| + }, {
|
| + // Greek
|
| + "el-GR", L"0123456789" L"\x03B1", true,
|
| + }, {
|
| + // Russian
|
| + "ru-RU", L"0123456789" L"\x0430", true,
|
| + }, {
|
| + // Hebrew
|
| + "he-IL", L"0123456789" L"\x05D0", false,
|
| + }, {
|
| + // Arabic
|
| + "ar", L"0123456789" L"\x0627", false,
|
| + }, {
|
| + // Hindi
|
| + "hi-IN", L"0123456789" L"\x0905", true,
|
| + }, {
|
| + // Thai
|
| + "th-TH", L"0123456789" L"\x0e01", true,
|
| + }, {
|
| + // Korean
|
| + "ko-KR", L"0123456789" L"\x1100\x1161", true,
|
| + },
|
| + };
|
| +
|
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
|
| + SCOPED_TRACE(base::StringPrintf("kTestCases[%" PRIuS "]: language=%s", i,
|
| + kTestCases[i].language));
|
| +
|
| + SpellcheckCharAttribute attributes;
|
| + attributes.SetDefaultLanguage(kTestCases[i].language);
|
| +
|
| + string16 input_word(WideToUTF16(kTestCases[i].text));
|
| + SpellcheckWordIterator iterator;
|
| + EXPECT_TRUE(iterator.Initialize(&attributes, true));
|
| + EXPECT_TRUE(iterator.SetText(input_word.c_str(), input_word.length()));
|
| +
|
| + string16 actual_word;
|
| + int actual_start, actual_end;
|
| + EXPECT_TRUE(iterator.GetNextWord(&actual_word, &actual_start, &actual_end));
|
| + if (kTestCases[i].left_to_right)
|
| + EXPECT_EQ(input_word, actual_word);
|
| + else
|
| + EXPECT_NE(input_word, actual_word);
|
| + }
|
| +}
|
|
|