| 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_split.h" | 13 #include "base/strings/string_split.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/common/spellcheck_common.h" | |
| 17 #include "chrome/common/spellcheck_result.h" | |
| 18 #include "chrome/renderer/spellchecker/spellcheck.h" | 16 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 19 #include "chrome/renderer/spellchecker/spellcheck_provider_test.h" | 17 #include "chrome/renderer/spellchecker/spellcheck_provider_test.h" |
| 18 #include "components/spellcheck/common/spellcheck_common.h" |
| 19 #include "components/spellcheck/common/spellcheck_result.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "third_party/WebKit/public/platform/WebString.h" | 21 #include "third_party/WebKit/public/platform/WebString.h" |
| 22 #include "third_party/WebKit/public/platform/WebVector.h" | 22 #include "third_party/WebKit/public/platform/WebVector.h" |
| 23 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" | 23 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 struct SpellcheckTestCase { | 27 struct SpellcheckTestCase { |
| 28 // A string of text for checking. | 28 // A string of text for checking. |
| 29 const wchar_t* input; | 29 const wchar_t* input; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 54 InitializeSpellCheck(unsplit_languages); | 54 InitializeSpellCheck(unsplit_languages); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void InitializeSpellCheck(const std::string& unsplit_languages) { | 57 void InitializeSpellCheck(const std::string& unsplit_languages) { |
| 58 base::FilePath hunspell_directory = GetHunspellDirectory(); | 58 base::FilePath hunspell_directory = GetHunspellDirectory(); |
| 59 EXPECT_FALSE(hunspell_directory.empty()); | 59 EXPECT_FALSE(hunspell_directory.empty()); |
| 60 std::vector<std::string> languages = base::SplitString( | 60 std::vector<std::string> languages = base::SplitString( |
| 61 unsplit_languages, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 61 unsplit_languages, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 62 | 62 |
| 63 for (const auto& language : languages) { | 63 for (const auto& language : languages) { |
| 64 base::File file(chrome::spellcheck_common::GetVersionedFileName( | 64 base::File file( |
| 65 language, hunspell_directory), | 65 spellcheck::GetVersionedFileName(language, hunspell_directory), |
| 66 base::File::FLAG_OPEN | base::File::FLAG_READ); | 66 base::File::FLAG_OPEN | base::File::FLAG_READ); |
| 67 spellcheck_->AddSpellcheckLanguage(std::move(file), language); | 67 spellcheck_->AddSpellcheckLanguage(std::move(file), language); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 ~MultilingualSpellCheckTest() override {} | 71 ~MultilingualSpellCheckTest() override {} |
| 72 TestingSpellCheckProvider* provider() { return provider_.get(); } | 72 TestingSpellCheckProvider* provider() { return provider_.get(); } |
| 73 | 73 |
| 74 protected: | 74 protected: |
| 75 void ExpectSpellCheckWordResults(const std::string& languages, | 75 void ExpectSpellCheckWordResults(const std::string& languages, |
| 76 const SpellcheckTestCase* test_cases, | 76 const SpellcheckTestCase* test_cases, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 base::WideToUTF16(kTestCases[i].expected_suggestions), | 247 base::WideToUTF16(kTestCases[i].expected_suggestions), |
| 248 base::string16(1, ','), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 248 base::string16(1, ','), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 249 | 249 |
| 250 EXPECT_EQ(expected_suggestions.size(), suggestions.size()); | 250 EXPECT_EQ(expected_suggestions.size(), suggestions.size()); |
| 251 for (size_t j = 0; | 251 for (size_t j = 0; |
| 252 j < std::min(expected_suggestions.size(), suggestions.size()); j++) { | 252 j < std::min(expected_suggestions.size(), suggestions.size()); j++) { |
| 253 EXPECT_EQ(expected_suggestions[j], base::string16(suggestions[j])); | 253 EXPECT_EQ(expected_suggestions[j], base::string16(suggestions[j])); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 } | 256 } |
| OLD | NEW |