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

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

Issue 2254533003: Rename spellcheck::pref::kEnableContinuousSpellcheck to ...::kEnableSpellcheck (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return static_cast<BrowserContext*>(browser()->profile()); 83 return static_cast<BrowserContext*>(browser()->profile());
84 } 84 }
85 85
86 PrefService* GetPrefs() { 86 PrefService* GetPrefs() {
87 return prefs_; 87 return prefs_;
88 } 88 }
89 89
90 void InitSpellcheck(bool enable_spellcheck, 90 void InitSpellcheck(bool enable_spellcheck,
91 const std::string& single_dictionary, 91 const std::string& single_dictionary,
92 const std::string& multiple_dictionaries) { 92 const std::string& multiple_dictionaries) {
93 prefs_->SetBoolean(spellcheck::prefs::kEnableContinuousSpellcheck, 93 prefs_->SetBoolean(spellcheck::prefs::kEnableSpellcheck,
94 enable_spellcheck); 94 enable_spellcheck);
95 prefs_->SetString(spellcheck::prefs::kSpellCheckDictionary, 95 prefs_->SetString(spellcheck::prefs::kSpellCheckDictionary,
96 single_dictionary); 96 single_dictionary);
97 base::ListValue dictionaries_value; 97 base::ListValue dictionaries_value;
98 dictionaries_value.AppendStrings( 98 dictionaries_value.AppendStrings(
99 base::SplitString(multiple_dictionaries, ",", base::TRIM_WHITESPACE, 99 base::SplitString(multiple_dictionaries, ",", base::TRIM_WHITESPACE,
100 base::SPLIT_WANT_NONEMPTY)); 100 base::SPLIT_WANT_NONEMPTY));
101 prefs_->Set(spellcheck::prefs::kSpellCheckDictionaries, dictionaries_value); 101 prefs_->Set(spellcheck::prefs::kSpellCheckDictionaries, dictionaries_value);
102 SpellcheckService* spellcheck = 102 SpellcheckService* spellcheck =
103 SpellcheckServiceFactory::GetForRenderProcessId(renderer_->GetID()); 103 SpellcheckServiceFactory::GetForRenderProcessId(renderer_->GetID());
104 ASSERT_NE(nullptr, spellcheck); 104 ASSERT_NE(nullptr, spellcheck);
105 spellcheck->InitForRenderer(renderer_.get()); 105 spellcheck->InitForRenderer(renderer_.get());
106 } 106 }
107 107
108 void EnableSpellcheck(bool enable_spellcheck) { 108 void EnableSpellcheck(bool enable_spellcheck) {
109 ScopedPreferenceChange scope(&renderer_->sink()); 109 ScopedPreferenceChange scope(&renderer_->sink());
110 prefs_->SetBoolean(spellcheck::prefs::kEnableContinuousSpellcheck, 110 prefs_->SetBoolean(spellcheck::prefs::kEnableSpellcheck,
111 enable_spellcheck); 111 enable_spellcheck);
112 } 112 }
113 113
114 void SetSingleLanguageDictionary(const std::string& single_dictionary) { 114 void SetSingleLanguageDictionary(const std::string& single_dictionary) {
115 ScopedPreferenceChange scope(&renderer_->sink()); 115 ScopedPreferenceChange scope(&renderer_->sink());
116 prefs_->SetString(spellcheck::prefs::kSpellCheckDictionary, 116 prefs_->SetString(spellcheck::prefs::kSpellCheckDictionary,
117 single_dictionary); 117 single_dictionary);
118 } 118 }
119 119
120 void SetMultiLingualDictionaries(const std::string& multiple_dictionaries) { 120 void SetMultiLingualDictionaries(const std::string& multiple_dictionaries) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 GetPrefs()->GetString(spellcheck::prefs::kSpellCheckDictionary).empty()); 353 GetPrefs()->GetString(spellcheck::prefs::kSpellCheckDictionary).empty());
354 } 354 }
355 355
356 // Checks that, if a user has spellchecking disabled, nothing changes 356 // Checks that, if a user has spellchecking disabled, nothing changes
357 // during migration. 357 // during migration.
358 IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest, 358 IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest,
359 SpellcheckingDisabledPreferenceMigration) { 359 SpellcheckingDisabledPreferenceMigration) {
360 base::ListValue dictionaries; 360 base::ListValue dictionaries;
361 dictionaries.AppendString("en-US"); 361 dictionaries.AppendString("en-US");
362 GetPrefs()->Set(spellcheck::prefs::kSpellCheckDictionaries, dictionaries); 362 GetPrefs()->Set(spellcheck::prefs::kSpellCheckDictionaries, dictionaries);
363 GetPrefs()->SetBoolean(spellcheck::prefs::kEnableContinuousSpellcheck, false); 363 GetPrefs()->SetBoolean(spellcheck::prefs::kEnableSpellcheck, false);
364 364
365 // Migrate the preferences. 365 // Migrate the preferences.
366 SpellcheckServiceFactory::GetForContext(GetContext()); 366 SpellcheckServiceFactory::GetForContext(GetContext());
367 367
368 EXPECT_FALSE( 368 EXPECT_FALSE(
369 GetPrefs()->GetBoolean(spellcheck::prefs::kEnableContinuousSpellcheck)); 369 GetPrefs()->GetBoolean(spellcheck::prefs::kEnableSpellcheck));
370 EXPECT_EQ(1U, GetPrefs() 370 EXPECT_EQ(1U, GetPrefs()
371 ->GetList(spellcheck::prefs::kSpellCheckDictionaries) 371 ->GetList(spellcheck::prefs::kSpellCheckDictionaries)
372 ->GetSize()); 372 ->GetSize());
373 } 373 }
374 374
375 // Make sure preferences get preserved and spellchecking stays enabled. 375 // Make sure preferences get preserved and spellchecking stays enabled.
376 IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest, 376 IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest,
377 MultilingualPreferenceNotMigrated) { 377 MultilingualPreferenceNotMigrated) {
378 base::ListValue dictionaries; 378 base::ListValue dictionaries;
379 dictionaries.AppendString("en-US"); 379 dictionaries.AppendString("en-US");
380 dictionaries.AppendString("fr"); 380 dictionaries.AppendString("fr");
381 GetPrefs()->Set(spellcheck::prefs::kSpellCheckDictionaries, dictionaries); 381 GetPrefs()->Set(spellcheck::prefs::kSpellCheckDictionaries, dictionaries);
382 GetPrefs()->SetBoolean(spellcheck::prefs::kEnableContinuousSpellcheck, true); 382 GetPrefs()->SetBoolean(spellcheck::prefs::kEnableSpellcheck, true);
383 383
384 // Should not migrate any preferences. 384 // Should not migrate any preferences.
385 SpellcheckServiceFactory::GetForContext(GetContext()); 385 SpellcheckServiceFactory::GetForContext(GetContext());
386 386
387 EXPECT_TRUE( 387 EXPECT_TRUE(
388 GetPrefs()->GetBoolean(spellcheck::prefs::kEnableContinuousSpellcheck)); 388 GetPrefs()->GetBoolean(spellcheck::prefs::kEnableSpellcheck));
389 EXPECT_EQ(2U, GetPrefs() 389 EXPECT_EQ(2U, GetPrefs()
390 ->GetList(spellcheck::prefs::kSpellCheckDictionaries) 390 ->GetList(spellcheck::prefs::kSpellCheckDictionaries)
391 ->GetSize()); 391 ->GetSize());
392 std::string pref; 392 std::string pref;
393 ASSERT_TRUE(GetPrefs() 393 ASSERT_TRUE(GetPrefs()
394 ->GetList(spellcheck::prefs::kSpellCheckDictionaries) 394 ->GetList(spellcheck::prefs::kSpellCheckDictionaries)
395 ->GetString(0, &pref)); 395 ->GetString(0, &pref));
396 EXPECT_EQ("en-US", pref); 396 EXPECT_EQ("en-US", pref);
397 ASSERT_TRUE(GetPrefs() 397 ASSERT_TRUE(GetPrefs()
398 ->GetList(spellcheck::prefs::kSpellCheckDictionaries) 398 ->GetList(spellcheck::prefs::kSpellCheckDictionaries)
399 ->GetString(1, &pref)); 399 ->GetString(1, &pref));
400 EXPECT_EQ("fr", pref); 400 EXPECT_EQ("fr", pref);
401 } 401 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_service.cc ('k') | chrome/browser/spellchecker/spelling_service_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698