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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_service_browsertest.cc

Issue 2177343002: Componentize spellcheck [2]: move common/ files to component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move message generator to component Created 4 years, 4 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
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 "chrome/browser/spellchecker/spellcheck_service.h" 5 #include "chrome/browser/spellchecker/spellcheck_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 #include <tuple> 10 #include <tuple>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/spellchecker/spellcheck_factory.h" 22 #include "chrome/browser/spellchecker/spellcheck_factory.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/spellcheck_common.h"
28 #include "chrome/common/spellcheck_messages.h"
29 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
30 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
29 #include "components/spellcheck/common/spellcheck_common.h"
30 #include "components/spellcheck/common/spellcheck_messages.h"
31 #include "components/user_prefs/user_prefs.h" 31 #include "components/user_prefs/user_prefs.h"
32 #include "content/public/test/mock_render_process_host.h" 32 #include "content/public/test/mock_render_process_host.h"
33 #include "content/public/test/test_utils.h" 33 #include "content/public/test/test_utils.h"
34 #include "url/gurl.h" 34 #include "url/gurl.h"
35 35
36 using content::BrowserContext; 36 using content::BrowserContext;
37 37
38 namespace { 38 namespace {
39 39
40 // A corrupted BDICT data used in DeleteCorruptedBDICT. Please do not use this 40 // A corrupted BDICT data used in DeleteCorruptedBDICT. Please do not use this
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 EXPECT_TRUE(GetFirstEnableSpellcheckMessageParam()); 259 EXPECT_TRUE(GetFirstEnableSpellcheckMessageParam());
260 } 260 }
261 261
262 // Tests that we can delete a corrupted BDICT file used by hunspell. We do not 262 // Tests that we can delete a corrupted BDICT file used by hunspell. We do not
263 // run this test on Mac because Mac does not use hunspell by default. 263 // run this test on Mac because Mac does not use hunspell by default.
264 IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest, DeleteCorruptedBDICT) { 264 IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest, DeleteCorruptedBDICT) {
265 // Write the corrupted BDICT data to create a corrupted BDICT file. 265 // Write the corrupted BDICT data to create a corrupted BDICT file.
266 base::FilePath dict_dir; 266 base::FilePath dict_dir;
267 ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir)); 267 ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir));
268 base::FilePath bdict_path = 268 base::FilePath bdict_path =
269 chrome::spellcheck_common::GetVersionedFileName("en-US", dict_dir); 269 spellcheck::GetVersionedFileName("en-US", dict_dir);
270 270
271 size_t actual = base::WriteFile(bdict_path, 271 size_t actual = base::WriteFile(bdict_path,
272 reinterpret_cast<const char*>(kCorruptedBDICT), 272 reinterpret_cast<const char*>(kCorruptedBDICT),
273 arraysize(kCorruptedBDICT)); 273 arraysize(kCorruptedBDICT));
274 EXPECT_EQ(arraysize(kCorruptedBDICT), actual); 274 EXPECT_EQ(arraysize(kCorruptedBDICT), actual);
275 275
276 // Attach an event to the SpellcheckService object so we can receive its 276 // Attach an event to the SpellcheckService object so we can receive its
277 // status updates. 277 // status updates.
278 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL, 278 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
279 base::WaitableEvent::InitialState::NOT_SIGNALED); 279 base::WaitableEvent::InitialState::NOT_SIGNALED);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 EXPECT_TRUE(GetPrefs()->GetBoolean(prefs::kEnableContinuousSpellcheck)); 376 EXPECT_TRUE(GetPrefs()->GetBoolean(prefs::kEnableContinuousSpellcheck));
377 EXPECT_EQ(2U, GetPrefs()->GetList(prefs::kSpellCheckDictionaries)->GetSize()); 377 EXPECT_EQ(2U, GetPrefs()->GetList(prefs::kSpellCheckDictionaries)->GetSize());
378 std::string pref; 378 std::string pref;
379 ASSERT_TRUE( 379 ASSERT_TRUE(
380 GetPrefs()->GetList(prefs::kSpellCheckDictionaries)->GetString(0, &pref)); 380 GetPrefs()->GetList(prefs::kSpellCheckDictionaries)->GetString(0, &pref));
381 EXPECT_EQ("en-US", pref); 381 EXPECT_EQ("en-US", pref);
382 ASSERT_TRUE( 382 ASSERT_TRUE(
383 GetPrefs()->GetList(prefs::kSpellCheckDictionaries)->GetString(1, &pref)); 383 GetPrefs()->GetList(prefs::kSpellCheckDictionaries)->GetString(1, &pref));
384 EXPECT_EQ("fr", pref); 384 EXPECT_EQ("fr", pref);
385 } 385 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_service.cc ('k') | chrome/browser/spellchecker/spellchecker_session_bridge_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698