| 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 "webkit/glue/webkit_glue.h" | 5 #include "webkit/glue/webkit_glue.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| 11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/renderer/spellchecker/spellcheck.h" | 13 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/spellcheck_common.h" | 15 #include "chrome/common/spellcheck_common.h" |
| 16 #include "chrome/common/spellcheck_result.h" | 16 #include "chrome/common/spellcheck_result.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingComple
tion.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingComple
tion.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult
.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult
.h" |
| 20 | 20 |
| 21 | |
| 22 namespace { | 21 namespace { |
| 23 | 22 |
| 24 FilePath GetHunspellDirectory() { | 23 FilePath GetHunspellDirectory() { |
| 25 FilePath hunspell_directory; | 24 FilePath hunspell_directory; |
| 26 if (!PathService::Get(base::DIR_SOURCE_ROOT, &hunspell_directory)) | 25 if (!PathService::Get(base::DIR_SOURCE_ROOT, &hunspell_directory)) |
| 27 return FilePath(); | 26 return FilePath(); |
| 28 | 27 |
| 29 hunspell_directory = hunspell_directory.AppendASCII("third_party"); | 28 hunspell_directory = hunspell_directory.AppendASCII("third_party"); |
| 30 hunspell_directory = hunspell_directory.AppendASCII("hunspell_dictionaries"); | 29 hunspell_directory = hunspell_directory.AppendASCII("hunspell_dictionaries"); |
| 31 return hunspell_directory; | 30 return hunspell_directory; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 45 } | 44 } |
| 46 | 45 |
| 47 void UninitializeSpellCheck() { | 46 void UninitializeSpellCheck() { |
| 48 spell_check_.reset(new SpellCheck()); | 47 spell_check_.reset(new SpellCheck()); |
| 49 } | 48 } |
| 50 | 49 |
| 51 void InitializeSpellCheck(const std::string& language) { | 50 void InitializeSpellCheck(const std::string& language) { |
| 52 FilePath hunspell_directory = GetHunspellDirectory(); | 51 FilePath hunspell_directory = GetHunspellDirectory(); |
| 53 EXPECT_FALSE(hunspell_directory.empty()); | 52 EXPECT_FALSE(hunspell_directory.empty()); |
| 54 base::PlatformFile file = base::CreatePlatformFile( | 53 base::PlatformFile file = base::CreatePlatformFile( |
| 55 SpellCheckCommon::GetVersionedFileName(language, hunspell_directory), | 54 chrome::spellcheck_common::GetVersionedFileName(language, |
| 55 hunspell_directory), |
| 56 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL, NULL); | 56 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL, NULL); |
| 57 spell_check_->Init( | 57 spell_check_->Init( |
| 58 file, std::vector<std::string>(), language); | 58 file, std::vector<std::string>(), language); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual ~SpellCheckTest() { | 61 virtual ~SpellCheckTest() { |
| 62 } | 62 } |
| 63 | 63 |
| 64 SpellCheck* spell_check() { return spell_check_.get(); } | 64 SpellCheck* spell_check() { return spell_check_.get(); } |
| 65 | 65 |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 spell_check()->CreateTextCheckingResults( | 1013 spell_check()->CreateTextCheckingResults( |
| 1014 0, text, spellcheck_results, &textcheck_results); | 1014 0, text, spellcheck_results, &textcheck_results); |
| 1015 EXPECT_EQ(spellcheck_results.size(), textcheck_results.size()); | 1015 EXPECT_EQ(spellcheck_results.size(), textcheck_results.size()); |
| 1016 EXPECT_EQ(WebKit::WebTextCheckingTypeGrammar, textcheck_results[0].type); | 1016 EXPECT_EQ(WebKit::WebTextCheckingTypeGrammar, textcheck_results[0].type); |
| 1017 EXPECT_EQ(spellcheck_results[0].location, textcheck_results[0].location); | 1017 EXPECT_EQ(spellcheck_results[0].location, textcheck_results[0].location); |
| 1018 EXPECT_EQ(spellcheck_results[0].length, textcheck_results[0].length); | 1018 EXPECT_EQ(spellcheck_results[0].length, textcheck_results[0].length); |
| 1019 } | 1019 } |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 #endif | 1022 #endif |
| OLD | NEW |