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

Unified Diff: chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments. merge to ToT. Murder a DB thread and more TestBrowserThreads. Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc
diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc
index 58c3d1b4c0487199ed18875d3523215c2de3778d..a85c7e49a4466e5ea64ec129f49600d650412ac4 100644
--- a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc
+++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc
@@ -5,7 +5,6 @@
#include <vector>
#include "base/file_util.h"
-#include "base/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/statistics_recorder.h"
@@ -17,7 +16,8 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/spellcheck_common.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "net/url_request/test_url_fetcher_factory.h"
#include "sync/api/sync_change.h"
#include "sync/api/sync_data.h"
#include "sync/api/sync_error_factory.h"
@@ -29,7 +29,6 @@
using base::HistogramBase;
using base::HistogramSamples;
using base::StatisticsRecorder;
-using content::BrowserThread;
using chrome::spellcheck_common::WordList;
using chrome::spellcheck_common::WordSet;
@@ -60,24 +59,14 @@ static BrowserContextKeyedService* BuildSpellcheckService(
class SpellcheckCustomDictionaryTest : public testing::Test {
protected:
- SpellcheckCustomDictionaryTest()
- : ui_thread_(BrowserThread::UI, &message_loop_),
- file_thread_(BrowserThread::FILE, &message_loop_),
- profile_(new TestingProfile) {
- }
-
virtual void SetUp() OVERRIDE {
// Use SetTestingFactoryAndUse to force creation and initialization.
SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_.get(), &BuildSpellcheckService);
+ &profile_, &BuildSpellcheckService);
StatisticsRecorder::Initialize();
}
- virtual void TearDown() OVERRIDE {
- base::MessageLoop::current()->RunUntilIdle();
- }
-
// A wrapper around SpellcheckCustomDictionary::LoadDictionaryFile private
// function to avoid a large number of FRIEND_TEST declarations in
// SpellcheckCustomDictionary.
@@ -112,11 +101,10 @@ class SpellcheckCustomDictionaryTest : public testing::Test {
return dictionary.Apply(change);
}
- base::MessageLoop message_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread file_thread_;
+ content::TestBrowserThreadBundle thread_bundle_;
- scoped_ptr<TestingProfile> profile_;
+ TestingProfile profile_;
+ net::TestURLFetcherFactory fetcher_factory_;
};
// A wrapper around SpellcheckCustomDictionary that does not own the wrapped
@@ -187,7 +175,7 @@ class DictionaryObserverCounter : public SpellcheckCustomDictionary::Observer {
TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) {
base::FilePath path =
- profile_->GetPath().Append(chrome::kCustomDictionaryFileName);
+ profile_.GetPath().Append(chrome::kCustomDictionaryFileName);
WordList loaded_custom_words = LoadDictionaryFile(path);
// The custom word list should be empty now.
@@ -217,7 +205,7 @@ TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) {
TEST_F(SpellcheckCustomDictionaryTest, MultiProfile) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -251,7 +239,7 @@ TEST_F(SpellcheckCustomDictionaryTest, MultiProfile) {
// Legacy empty dictionary should be converted to new format empty dictionary.
TEST_F(SpellcheckCustomDictionaryTest, LegacyEmptyDictionaryShouldBeConverted) {
base::FilePath path =
- profile_->GetPath().Append(chrome::kCustomDictionaryFileName);
+ profile_.GetPath().Append(chrome::kCustomDictionaryFileName);
std::string content;
file_util::WriteFile(path, content.c_str(), content.length());
@@ -264,7 +252,7 @@ TEST_F(SpellcheckCustomDictionaryTest, LegacyEmptyDictionaryShouldBeConverted) {
TEST_F(SpellcheckCustomDictionaryTest,
LegacyDictionaryWithTwoWordsShouldBeConverted) {
base::FilePath path =
- profile_->GetPath().Append(chrome::kCustomDictionaryFileName);
+ profile_.GetPath().Append(chrome::kCustomDictionaryFileName);
std::string content = "foo\nbar\nfoo\n";
file_util::WriteFile(path, content.c_str(), content.length());
@@ -280,7 +268,7 @@ TEST_F(SpellcheckCustomDictionaryTest,
TEST_F(SpellcheckCustomDictionaryTest,
IllegalWordsShouldBeRemovedFromDictionary) {
base::FilePath path =
- profile_->GetPath().Append(chrome::kCustomDictionaryFileName);
+ profile_.GetPath().Append(chrome::kCustomDictionaryFileName);
std::string content = "foo\n foo bar \n\n \nbar\n"
"01234567890123456789012345678901234567890123456789"
@@ -299,7 +287,7 @@ TEST_F(SpellcheckCustomDictionaryTest,
// previous version should be reloaded.
TEST_F(SpellcheckCustomDictionaryTest, CorruptedWriteShouldBeRecovered) {
base::FilePath path =
- profile_->GetPath().Append(chrome::kCustomDictionaryFileName);
+ profile_.GetPath().Append(chrome::kCustomDictionaryFileName);
std::string content = "foo\nbar";
file_util::WriteFile(path, content.c_str(), content.length());
@@ -324,7 +312,7 @@ TEST_F(SpellcheckCustomDictionaryTest,
GetAllSyncDataAccuratelyReflectsDictionaryState) {
SpellcheckCustomDictionary* dictionary =
SpellcheckServiceFactory::GetForProfile(
- profile_.get())->GetCustomDictionary();
+ &profile_)->GetCustomDictionary();
syncer::SyncDataList data = dictionary->GetAllSyncData(syncer::DICTIONARY);
EXPECT_TRUE(data.empty());
@@ -354,7 +342,7 @@ TEST_F(SpellcheckCustomDictionaryTest,
TEST_F(SpellcheckCustomDictionaryTest, GetAllSyncDataHasLimit) {
SpellcheckCustomDictionary* dictionary =
SpellcheckServiceFactory::GetForProfile(
- profile_.get())->GetCustomDictionary();
+ &profile_)->GetCustomDictionary();
SpellcheckCustomDictionary::Change change;
for (size_t i = 0;
@@ -389,7 +377,7 @@ TEST_F(SpellcheckCustomDictionaryTest, GetAllSyncDataHasLimit) {
TEST_F(SpellcheckCustomDictionaryTest, ProcessSyncChanges) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* dictionary =
spellcheck_service->GetCustomDictionary();
@@ -460,7 +448,7 @@ TEST_F(SpellcheckCustomDictionaryTest, ProcessSyncChanges) {
TEST_F(SpellcheckCustomDictionaryTest, MergeDataAndStartSyncing) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -506,7 +494,7 @@ TEST_F(SpellcheckCustomDictionaryTest, MergeDataAndStartSyncing) {
TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigBeforeSyncing) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -549,7 +537,7 @@ TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigBeforeSyncing) {
TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigAndServerFull) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -601,7 +589,7 @@ TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigAndServerFull) {
TEST_F(SpellcheckCustomDictionaryTest, ServerTooBig) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -652,7 +640,7 @@ TEST_F(SpellcheckCustomDictionaryTest, ServerTooBig) {
TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToStartSyncing) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -698,7 +686,7 @@ TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToStartSyncing) {
TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToContiueSyncing) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -749,7 +737,7 @@ TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToContiueSyncing) {
TEST_F(SpellcheckCustomDictionaryTest, LoadAfterSyncStart) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -787,7 +775,7 @@ TEST_F(SpellcheckCustomDictionaryTest, LoadAfterSyncStart) {
TEST_F(SpellcheckCustomDictionaryTest, LoadAfterSyncStartTooBigToSync) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -834,7 +822,7 @@ TEST_F(SpellcheckCustomDictionaryTest, LoadAfterSyncStartTooBigToSync) {
TEST_F(SpellcheckCustomDictionaryTest, LoadDuplicatesAfterSync) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -881,7 +869,7 @@ TEST_F(SpellcheckCustomDictionaryTest, LoadDuplicatesAfterSync) {
TEST_F(SpellcheckCustomDictionaryTest, DictionaryLoadNotification) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
@@ -902,7 +890,7 @@ TEST_F(SpellcheckCustomDictionaryTest, DictionaryLoadNotification) {
TEST_F(SpellcheckCustomDictionaryTest, DictionaryAddWordNotification) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
@@ -922,7 +910,7 @@ TEST_F(SpellcheckCustomDictionaryTest, DictionaryAddWordNotification) {
TEST_F(SpellcheckCustomDictionaryTest, DictionaryRemoveWordNotification) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
@@ -945,7 +933,7 @@ TEST_F(SpellcheckCustomDictionaryTest, DictionaryRemoveWordNotification) {
TEST_F(SpellcheckCustomDictionaryTest, DictionarySyncNotification) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
TestingProfile profile2;
@@ -1006,7 +994,7 @@ TEST_F(SpellcheckCustomDictionaryTest, DictionarySyncLimit) {
// Upload the maximum number of words to the sync server.
{
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
@@ -1092,7 +1080,7 @@ TEST_F(SpellcheckCustomDictionaryTest, RecordSizeStatsCorrectly) {
// Load the dictionary which should be empty.
base::FilePath path =
- profile_->GetPath().Append(chrome::kCustomDictionaryFileName);
+ profile_.GetPath().Append(chrome::kCustomDictionaryFileName);
WordList loaded_custom_words = LoadDictionaryFile(path);
EXPECT_EQ(0u, loaded_custom_words.size());
@@ -1125,7 +1113,7 @@ TEST_F(SpellcheckCustomDictionaryTest, RecordSizeStatsCorrectly) {
TEST_F(SpellcheckCustomDictionaryTest, HasWord) {
SpellcheckService* spellcheck_service =
- SpellcheckServiceFactory::GetForProfile(profile_.get());
+ SpellcheckServiceFactory::GetForProfile(&profile_);
SpellcheckCustomDictionary* custom_dictionary =
spellcheck_service->GetCustomDictionary();
OnLoaded(*custom_dictionary, WordList());

Powered by Google App Engine
This is Rietveld 408576698