Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Side by Side Diff: chrome/renderer/spellchecker/spellcheck_unittest.cc

Issue 209193002: Remove PlatformFile from spell checker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert IsEnabled behavior Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/platform_file.h" 8 #include "base/platform_file.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 spell_check_.reset(new SpellCheck()); 48 spell_check_.reset(new SpellCheck());
49 } 49 }
50 50
51 bool InitializeIfNeeded() { 51 bool InitializeIfNeeded() {
52 return spell_check()->InitializeIfNeeded(); 52 return spell_check()->InitializeIfNeeded();
53 } 53 }
54 54
55 void InitializeSpellCheck(const std::string& language) { 55 void InitializeSpellCheck(const std::string& language) {
56 base::FilePath hunspell_directory = GetHunspellDirectory(); 56 base::FilePath hunspell_directory = GetHunspellDirectory();
57 EXPECT_FALSE(hunspell_directory.empty()); 57 EXPECT_FALSE(hunspell_directory.empty());
58 base::PlatformFile file = base::CreatePlatformFile( 58 base::File file(
59 chrome::spellcheck_common::GetVersionedFileName(language, 59 chrome::spellcheck_common::GetVersionedFileName(language,
60 hunspell_directory), 60 hunspell_directory),
61 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL, NULL); 61 base::File::FLAG_OPEN | base::File::FLAG_READ);
62 #if defined(OS_MACOSX) 62 #if defined(OS_MACOSX)
63 // TODO(groby): Forcing spellcheck to use hunspell, even on OSX. 63 // TODO(groby): Forcing spellcheck to use hunspell, even on OSX.
64 // Instead, tests should exercise individual spelling engines. 64 // Instead, tests should exercise individual spelling engines.
65 spell_check_->spellcheck_.platform_spelling_engine_.reset( 65 spell_check_->spellcheck_.platform_spelling_engine_.reset(
66 new HunspellEngine); 66 new HunspellEngine);
67 #endif 67 #endif
68 spell_check_->Init(file, std::set<std::string>(), language); 68 spell_check_->Init(file.Pass(), std::set<std::string>(), language);
69 } 69 }
70 70
71 void EnableAutoCorrect(bool enable_autocorrect) { 71 void EnableAutoCorrect(bool enable_autocorrect) {
72 spell_check_->OnEnableAutoSpellCorrect(enable_autocorrect); 72 spell_check_->OnEnableAutoSpellCorrect(enable_autocorrect);
73 } 73 }
74 74
75 virtual ~SpellCheckTest() { 75 virtual ~SpellCheckTest() {
76 } 76 }
77 77
78 SpellCheck* spell_check() { return spell_check_.get(); } 78 SpellCheck* spell_check() { return spell_check_.get(); }
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 strlen(kTestCases[i].misspelled), 1353 strlen(kTestCases[i].misspelled),
1354 0, 1354 0,
1355 &misspelling_start, 1355 &misspelling_start,
1356 &misspelling_length, 1356 &misspelling_length,
1357 &suggestions)); 1357 &suggestions));
1358 EXPECT_GE(suggestions.size(), static_cast<size_t>(1)); 1358 EXPECT_GE(suggestions.size(), static_cast<size_t>(1));
1359 if (suggestions.size() > 0) 1359 if (suggestions.size() > 0)
1360 EXPECT_EQ(suggestions[0], base::ASCIIToUTF16(kTestCases[i].suggestion)); 1360 EXPECT_EQ(suggestions[0], base::ASCIIToUTF16(kTestCases[i].suggestion));
1361 } 1361 }
1362 } 1362 }
OLDNEW
« no previous file with comments | « chrome/renderer/spellchecker/spellcheck_language.cc ('k') | chrome/renderer/spellchecker/spelling_engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698