OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 protected: | 75 protected: |
76 void ExpectSpellCheckWordResults(const std::string& languages, | 76 void ExpectSpellCheckWordResults(const std::string& languages, |
77 const SpellcheckTestCase* test_cases, | 77 const SpellcheckTestCase* test_cases, |
78 size_t num_test_cases) { | 78 size_t num_test_cases) { |
79 ReinitializeSpellCheck(languages); | 79 ReinitializeSpellCheck(languages); |
80 | 80 |
81 for (size_t i = 0; i < num_test_cases; ++i) { | 81 for (size_t i = 0; i < num_test_cases; ++i) { |
82 int misspelling_start = 0; | 82 int misspelling_start = 0; |
83 int misspelling_length = 0; | 83 int misspelling_length = 0; |
84 static_cast<blink::WebSpellCheckClient*>(provider()) | 84 static_cast<blink::WebTextCheckClient*>(provider()) |
85 ->checkSpelling(blink::WebString::fromUTF16( | 85 ->checkSpelling(blink::WebString::fromUTF16( |
86 base::WideToUTF16(test_cases[i].input)), | 86 base::WideToUTF16(test_cases[i].input)), |
87 misspelling_start, misspelling_length, nullptr); | 87 misspelling_start, misspelling_length, nullptr); |
88 | 88 |
89 EXPECT_EQ(test_cases[i].expected_misspelling_start, misspelling_start) | 89 EXPECT_EQ(test_cases[i].expected_misspelling_start, misspelling_start) |
90 << "Improper misspelling location found with the languages " | 90 << "Improper misspelling location found with the languages " |
91 << languages << " when checking \"" << test_cases[i].input << "\"."; | 91 << languages << " when checking \"" << test_cases[i].input << "\"."; |
92 EXPECT_EQ(test_cases[i].expected_misspelling_length, misspelling_length) | 92 EXPECT_EQ(test_cases[i].expected_misspelling_length, misspelling_length) |
93 << "Improper misspelling length found with the languages " | 93 << "Improper misspelling length found with the languages " |
94 << languages << " when checking \"" << test_cases[i].input << "\"."; | 94 << languages << " when checking \"" << test_cases[i].input << "\"."; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 {L"destruyan", 0, 0}, | 228 {L"destruyan", 0, 0}, |
229 {L"rocet", 0, 5, L"rocket,roce,crochet,troce,rocen"}, | 229 {L"rocet", 0, 5, L"rocket,roce,crochet,troce,rocen"}, |
230 {L"jum", 0, 3, L"hum,jun,ju,um,juma"}, | 230 {L"jum", 0, 3, L"hum,jun,ju,um,juma"}, |
231 {L"asdne", 0, 5, L"sadness,desasne"}, | 231 {L"asdne", 0, 5, L"sadness,desasne"}, |
232 }; | 232 }; |
233 | 233 |
234 for (size_t i = 0; i < arraysize(kTestCases); ++i) { | 234 for (size_t i = 0; i < arraysize(kTestCases); ++i) { |
235 blink::WebVector<blink::WebString> suggestions; | 235 blink::WebVector<blink::WebString> suggestions; |
236 int misspelling_start; | 236 int misspelling_start; |
237 int misspelling_length; | 237 int misspelling_length; |
238 static_cast<blink::WebSpellCheckClient*>(provider()) | 238 static_cast<blink::WebTextCheckClient*>(provider()) |
239 ->checkSpelling( | 239 ->checkSpelling( |
240 blink::WebString::fromUTF16(base::WideToUTF16(kTestCases[i].input)), | 240 blink::WebString::fromUTF16(base::WideToUTF16(kTestCases[i].input)), |
241 misspelling_start, misspelling_length, &suggestions); | 241 misspelling_start, misspelling_length, &suggestions); |
242 | 242 |
243 EXPECT_EQ(kTestCases[i].expected_misspelling_start, misspelling_start); | 243 EXPECT_EQ(kTestCases[i].expected_misspelling_start, misspelling_start); |
244 EXPECT_EQ(kTestCases[i].expected_misspelling_length, misspelling_length); | 244 EXPECT_EQ(kTestCases[i].expected_misspelling_length, misspelling_length); |
245 if (!kTestCases[i].expected_suggestions) { | 245 if (!kTestCases[i].expected_suggestions) { |
246 EXPECT_EQ(0UL, suggestions.size()); | 246 EXPECT_EQ(0UL, suggestions.size()); |
247 continue; | 247 continue; |
248 } | 248 } |
249 | 249 |
250 std::vector<base::string16> expected_suggestions = base::SplitString( | 250 std::vector<base::string16> expected_suggestions = base::SplitString( |
251 base::WideToUTF16(kTestCases[i].expected_suggestions), | 251 base::WideToUTF16(kTestCases[i].expected_suggestions), |
252 base::string16(1, ','), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 252 base::string16(1, ','), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
253 | 253 |
254 EXPECT_EQ(expected_suggestions.size(), suggestions.size()); | 254 EXPECT_EQ(expected_suggestions.size(), suggestions.size()); |
255 for (size_t j = 0; | 255 for (size_t j = 0; |
256 j < std::min(expected_suggestions.size(), suggestions.size()); j++) { | 256 j < std::min(expected_suggestions.size(), suggestions.size()); j++) { |
257 EXPECT_EQ(expected_suggestions[j], suggestions[j].utf16()); | 257 EXPECT_EQ(expected_suggestions[j], suggestions[j].utf16()); |
258 } | 258 } |
259 } | 259 } |
260 } | 260 } |
OLD | NEW |