| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 17 #include "chrome/common/spellcheck_common.h" | 18 #include "chrome/common/spellcheck_common.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 hunspell_directory), | 70 hunspell_directory), |
| 70 base::File::FLAG_OPEN | base::File::FLAG_READ); | 71 base::File::FLAG_OPEN | base::File::FLAG_READ); |
| 71 #if defined(OS_MACOSX) | 72 #if defined(OS_MACOSX) |
| 72 // TODO(groby): Forcing spellcheck to use hunspell, even on OSX. | 73 // TODO(groby): Forcing spellcheck to use hunspell, even on OSX. |
| 73 // Instead, tests should exercise individual spelling engines. | 74 // Instead, tests should exercise individual spelling engines. |
| 74 spell_check_->languages_.push_back(new SpellcheckLanguage()); | 75 spell_check_->languages_.push_back(new SpellcheckLanguage()); |
| 75 spell_check_->languages_.front()->platform_spelling_engine_.reset( | 76 spell_check_->languages_.front()->platform_spelling_engine_.reset( |
| 76 new HunspellEngine); | 77 new HunspellEngine); |
| 77 spell_check_->languages_.front()->Init(file.Pass(), language); | 78 spell_check_->languages_.front()->Init(file.Pass(), language); |
| 78 #else | 79 #else |
| 79 spell_check_->AddSpellcheckLanguage(file.Pass(), language); | 80 spell_check_->AddSpellcheckLanguage(std::move(file), language); |
| 80 #endif | 81 #endif |
| 81 } | 82 } |
| 82 | 83 |
| 83 ~SpellCheckTest() override {} | 84 ~SpellCheckTest() override {} |
| 84 | 85 |
| 85 SpellCheck* spell_check() { return spell_check_.get(); } | 86 SpellCheck* spell_check() { return spell_check_.get(); } |
| 86 | 87 |
| 87 bool CheckSpelling(const std::string& word, int tag) { | 88 bool CheckSpelling(const std::string& word, int tag) { |
| 88 return spell_check_->languages_.front() | 89 return spell_check_->languages_.front() |
| 89 ->platform_spelling_engine_->CheckSpelling(base::ASCIIToUTF16(word), | 90 ->platform_spelling_engine_->CheckSpelling(base::ASCIIToUTF16(word), |
| (...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 // to be updated accordingly. | 1550 // to be updated accordingly. |
| 1550 ASSERT_EQ(5, chrome::spellcheck_common::kMaxSuggestions); | 1551 ASSERT_EQ(5, chrome::spellcheck_common::kMaxSuggestions); |
| 1551 FillSuggestions(suggestions_list, &suggestion_results); | 1552 FillSuggestions(suggestions_list, &suggestion_results); |
| 1552 ASSERT_EQ(5U, suggestion_results.size()); | 1553 ASSERT_EQ(5U, suggestion_results.size()); |
| 1553 EXPECT_EQ(base::ASCIIToUTF16("0foo"), suggestion_results[0]); | 1554 EXPECT_EQ(base::ASCIIToUTF16("0foo"), suggestion_results[0]); |
| 1554 EXPECT_EQ(base::ASCIIToUTF16("1foo"), suggestion_results[1]); | 1555 EXPECT_EQ(base::ASCIIToUTF16("1foo"), suggestion_results[1]); |
| 1555 EXPECT_EQ(base::ASCIIToUTF16("2foo"), suggestion_results[2]); | 1556 EXPECT_EQ(base::ASCIIToUTF16("2foo"), suggestion_results[2]); |
| 1556 EXPECT_EQ(base::ASCIIToUTF16("0bar"), suggestion_results[3]); | 1557 EXPECT_EQ(base::ASCIIToUTF16("0bar"), suggestion_results[3]); |
| 1557 EXPECT_EQ(base::ASCIIToUTF16("1bar"), suggestion_results[4]); | 1558 EXPECT_EQ(base::ASCIIToUTF16("1bar"), suggestion_results[4]); |
| 1558 } | 1559 } |
| OLD | NEW |