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 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/string_piece.h" |
13 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "components/spellcheck/common/spellcheck_common.h" | 17 #include "components/spellcheck/common/spellcheck_common.h" |
17 #include "components/spellcheck/common/spellcheck_result.h" | 18 #include "components/spellcheck/common/spellcheck_result.h" |
18 #include "components/spellcheck/renderer/spellcheck.h" | 19 #include "components/spellcheck/renderer/spellcheck.h" |
19 #include "components/spellcheck/renderer/spellcheck_provider_test.h" | 20 #include "components/spellcheck/renderer/spellcheck_provider_test.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/WebKit/public/platform/WebString.h" | 22 #include "third_party/WebKit/public/platform/WebString.h" |
22 #include "third_party/WebKit/public/platform/WebVector.h" | 23 #include "third_party/WebKit/public/platform/WebVector.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // A misspelled Greek word. | 131 // A misspelled Greek word. |
131 {L"rocket destruyan \x0432\x0441\x0435\x0445 \x03B1\x03B1\x03B1\x03B1", | 132 {L"rocket destruyan \x0432\x0441\x0435\x0445 \x03B1\x03B1\x03B1\x03B1", |
132 22, 4}, | 133 22, 4}, |
133 // An English word, then Russian, and then a misspelled English word. | 134 // An English word, then Russian, and then a misspelled English word. |
134 {L"rocket \x0432\x0441\x0435\x0445 rocktt", 12, 6}, | 135 {L"rocket \x0432\x0441\x0435\x0445 rocktt", 12, 6}, |
135 }; | 136 }; |
136 | 137 |
137 // A sorted list of languages. This must start sorted to get all possible | 138 // A sorted list of languages. This must start sorted to get all possible |
138 // permutations. | 139 // permutations. |
139 std::string languages = "el-GR,en-US,es-ES,ru-RU"; | 140 std::string languages = "el-GR,en-US,es-ES,ru-RU"; |
140 std::vector<std::string> permuted_languages = base::SplitString( | 141 std::vector<base::StringPiece> permuted_languages = base::SplitStringPiece( |
141 languages, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 142 languages, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
142 | 143 |
143 do { | 144 do { |
144 languages = base::JoinString(permuted_languages, ","); | 145 std::string reordered_languages = base::JoinString(permuted_languages, ","); |
145 ExpectSpellCheckWordResults(languages, kTestCases, arraysize(kTestCases)); | 146 ExpectSpellCheckWordResults(reordered_languages, kTestCases, |
| 147 arraysize(kTestCases)); |
146 } while (std::next_permutation(permuted_languages.begin(), | 148 } while (std::next_permutation(permuted_languages.begin(), |
147 permuted_languages.end())); | 149 permuted_languages.end())); |
148 } | 150 } |
149 | 151 |
150 TEST_F(MultilingualSpellCheckTest, MultilingualSpellCheckWordEnglishSpanish) { | 152 TEST_F(MultilingualSpellCheckTest, MultilingualSpellCheckWordEnglishSpanish) { |
151 static const SpellcheckTestCase kTestCases[] = { | 153 static const SpellcheckTestCase kTestCases[] = { |
152 {L"", 0, 0}, | 154 {L"", 0, 0}, |
153 {L"head hand foot legs arms", 0, 0}, | 155 {L"head hand foot legs arms", 0, 0}, |
154 {L"head hand foot legs arms zzzz", 25, 4}, | 156 {L"head hand foot legs arms zzzz", 25, 4}, |
155 {L"head hand zzzz foot legs arms", 10, 4}, | 157 {L"head hand zzzz foot legs arms", 10, 4}, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 base::WideToUTF16(kTestCases[i].expected_suggestions), | 251 base::WideToUTF16(kTestCases[i].expected_suggestions), |
250 base::string16(1, ','), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 252 base::string16(1, ','), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
251 | 253 |
252 EXPECT_EQ(expected_suggestions.size(), suggestions.size()); | 254 EXPECT_EQ(expected_suggestions.size(), suggestions.size()); |
253 for (size_t j = 0; | 255 for (size_t j = 0; |
254 j < std::min(expected_suggestions.size(), suggestions.size()); j++) { | 256 j < std::min(expected_suggestions.size(), suggestions.size()); j++) { |
255 EXPECT_EQ(expected_suggestions[j], suggestions[j].utf16()); | 257 EXPECT_EQ(expected_suggestions[j], suggestions[j].utf16()); |
256 } | 258 } |
257 } | 259 } |
258 } | 260 } |
OLD | NEW |