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

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

Issue 1165913002: [Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finish renaming profile -> context Created 5 years, 6 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_custom_dictionary.h" 5 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram_samples.h" 11 #include "base/metrics/histogram_samples.h"
11 #include "base/metrics/statistics_recorder.h" 12 #include "base/metrics/statistics_recorder.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "chrome/browser/spellchecker/spellcheck_factory.h" 14 #include "chrome/browser/spellchecker/spellcheck_factory.h"
14 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" 15 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
15 #include "chrome/browser/spellchecker/spellcheck_service.h" 16 #include "chrome/browser/spellchecker/spellcheck_service.h"
16 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
17 #include "chrome/common/spellcheck_common.h" 18 #include "chrome/common/spellcheck_common.h"
18 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
19 #include "content/public/test/test_browser_thread_bundle.h" 20 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 26 matching lines...) Expand all
46 for (const std::string& word : dictionary->GetWords()) { 47 for (const std::string& word : dictionary->GetWords()) {
47 sync_pb::EntitySpecifics specifics; 48 sync_pb::EntitySpecifics specifics;
48 specifics.mutable_dictionary()->set_word(word); 49 specifics.mutable_dictionary()->set_word(word);
49 data.push_back(syncer::SyncData::CreateLocalData(word, word, specifics)); 50 data.push_back(syncer::SyncData::CreateLocalData(word, word, specifics));
50 } 51 }
51 return data; 52 return data;
52 } 53 }
53 54
54 } // namespace 55 } // namespace
55 56
56 static KeyedService* BuildSpellcheckService(content::BrowserContext* profile) { 57 static scoped_ptr<KeyedService> BuildSpellcheckService(
57 return new SpellcheckService(static_cast<Profile*>(profile)); 58 content::BrowserContext* profile) {
59 return make_scoped_ptr(new SpellcheckService(static_cast<Profile*>(profile)));
58 } 60 }
59 61
60 class SpellcheckCustomDictionaryTest : public testing::Test { 62 class SpellcheckCustomDictionaryTest : public testing::Test {
61 protected: 63 protected:
62 void SetUp() override { 64 void SetUp() override {
63 // Use SetTestingFactoryAndUse to force creation and initialization. 65 // Use SetTestingFactoryAndUse to force creation and initialization.
64 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( 66 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse(
65 &profile_, &BuildSpellcheckService); 67 &profile_, &BuildSpellcheckService);
66 68
67 StatisticsRecorder::Initialize(); 69 StatisticsRecorder::Initialize();
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 SpellcheckServiceFactory::GetForContext(&profile_); 1213 SpellcheckServiceFactory::GetForContext(&profile_);
1212 SpellcheckCustomDictionary* custom_dictionary = 1214 SpellcheckCustomDictionary* custom_dictionary =
1213 spellcheck_service->GetCustomDictionary(); 1215 spellcheck_service->GetCustomDictionary();
1214 OnLoaded(*custom_dictionary, make_scoped_ptr(new std::set<std::string>)); 1216 OnLoaded(*custom_dictionary, make_scoped_ptr(new std::set<std::string>));
1215 EXPECT_FALSE(custom_dictionary->HasWord("foo")); 1217 EXPECT_FALSE(custom_dictionary->HasWord("foo"));
1216 EXPECT_FALSE(custom_dictionary->HasWord("bar")); 1218 EXPECT_FALSE(custom_dictionary->HasWord("bar"));
1217 custom_dictionary->AddWord("foo"); 1219 custom_dictionary->AddWord("foo");
1218 EXPECT_TRUE(custom_dictionary->HasWord("foo")); 1220 EXPECT_TRUE(custom_dictionary->HasWord("foo"));
1219 EXPECT_FALSE(custom_dictionary->HasWord("bar")); 1221 EXPECT_FALSE(custom_dictionary->HasWord("bar"));
1220 } 1222 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/test_signin_client_builder.cc ('k') | chrome/browser/spellchecker/spellcheck_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698