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