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 "components/spellcheck/renderer/spellcheck.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "chrome/renderer/spellchecker/hunspell_engine.h" | |
22 #include "chrome/renderer/spellchecker/spellcheck_language.h" | |
23 #include "components/spellcheck/common/spellcheck_common.h" | 21 #include "components/spellcheck/common/spellcheck_common.h" |
24 #include "components/spellcheck/common/spellcheck_result.h" | 22 #include "components/spellcheck/common/spellcheck_result.h" |
23 #include "components/spellcheck/renderer/hunspell_engine.h" | |
24 #include "components/spellcheck/renderer/spellcheck_language.h" | |
25 #include "components/test_runner/test_common.h" | |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 #include "third_party/WebKit/public/platform/WebVector.h" | 27 #include "third_party/WebKit/public/platform/WebVector.h" |
27 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" | 28 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
28 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" | 29 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
29 | 30 |
30 #define TYPOGRAPHICAL_APOSTROPHE L"\x2019" | 31 #define TYPOGRAPHICAL_APOSTROPHE L"\x2019" |
31 | 32 |
32 namespace { | 33 namespace { |
33 const int kNoOffset = 0; | 34 const int kNoOffset = 0; |
34 const int kNoTag = 0; | 35 const int kNoTag = 0; |
35 | 36 |
36 base::FilePath GetHunspellDirectory() { | 37 base::FilePath GetHunspellDirectory() { |
37 base::FilePath hunspell_directory; | 38 base::FilePath hunspell_directory; |
38 if (!PathService::Get(base::DIR_SOURCE_ROOT, &hunspell_directory)) | 39 if (!PathService::Get(base::DIR_SOURCE_ROOT, &hunspell_directory)) |
39 return base::FilePath(); | 40 return base::FilePath(); |
40 | 41 |
41 hunspell_directory = hunspell_directory.AppendASCII("third_party"); | 42 hunspell_directory = hunspell_directory.AppendASCII("third_party"); |
42 hunspell_directory = hunspell_directory.AppendASCII("hunspell_dictionaries"); | 43 hunspell_directory = hunspell_directory.AppendASCII("hunspell_dictionaries"); |
43 return hunspell_directory; | 44 return hunspell_directory; |
44 } | 45 } |
45 | 46 |
46 } // namespace | 47 } // namespace |
47 | 48 |
48 // TODO(groby): This needs to be a BrowserTest for OSX. | 49 // TODO(groby): This needs to be a BrowserTest for OSX. |
49 class SpellCheckTest : public testing::Test { | 50 class SpellCheckTest : public testing::Test { |
50 public: | 51 public: |
51 SpellCheckTest() { | 52 SpellCheckTest() { |
53 test_runner::EnsureBlinkInitialized(); | |
groby-ooo-7-16
2016/08/03 17:31:54
See above :)
timvolodine
2016/08/03 19:12:30
same answer ;)
| |
52 ReinitializeSpellCheck("en-US"); | 54 ReinitializeSpellCheck("en-US"); |
53 } | 55 } |
54 | 56 |
55 void ReinitializeSpellCheck(const std::string& language) { | 57 void ReinitializeSpellCheck(const std::string& language) { |
56 spell_check_.reset(new SpellCheck()); | 58 spell_check_.reset(new SpellCheck()); |
57 InitializeSpellCheck(language); | 59 InitializeSpellCheck(language); |
58 } | 60 } |
59 | 61 |
60 void UninitializeSpellCheck() { | 62 void UninitializeSpellCheck() { |
61 spell_check_.reset(new SpellCheck()); | 63 spell_check_.reset(new SpellCheck()); |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1561 // to be updated accordingly. | 1563 // to be updated accordingly. |
1562 ASSERT_EQ(5, spellcheck::kMaxSuggestions); | 1564 ASSERT_EQ(5, spellcheck::kMaxSuggestions); |
1563 FillSuggestions(suggestions_list, &suggestion_results); | 1565 FillSuggestions(suggestions_list, &suggestion_results); |
1564 ASSERT_EQ(5U, suggestion_results.size()); | 1566 ASSERT_EQ(5U, suggestion_results.size()); |
1565 EXPECT_EQ(base::ASCIIToUTF16("0foo"), suggestion_results[0]); | 1567 EXPECT_EQ(base::ASCIIToUTF16("0foo"), suggestion_results[0]); |
1566 EXPECT_EQ(base::ASCIIToUTF16("1foo"), suggestion_results[1]); | 1568 EXPECT_EQ(base::ASCIIToUTF16("1foo"), suggestion_results[1]); |
1567 EXPECT_EQ(base::ASCIIToUTF16("2foo"), suggestion_results[2]); | 1569 EXPECT_EQ(base::ASCIIToUTF16("2foo"), suggestion_results[2]); |
1568 EXPECT_EQ(base::ASCIIToUTF16("0bar"), suggestion_results[3]); | 1570 EXPECT_EQ(base::ASCIIToUTF16("0bar"), suggestion_results[3]); |
1569 EXPECT_EQ(base::ASCIIToUTF16("1bar"), suggestion_results[4]); | 1571 EXPECT_EQ(base::ASCIIToUTF16("1bar"), suggestion_results[4]); |
1570 } | 1572 } |
OLD | NEW |