| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 specifics.mutable_dictionary()->set_word(word); | 56 specifics.mutable_dictionary()->set_word(word); |
| 57 data.push_back(syncer::SyncData::CreateLocalData(word, word, specifics)); | 57 data.push_back(syncer::SyncData::CreateLocalData(word, word, specifics)); |
| 58 } | 58 } |
| 59 return data; | 59 return data; |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace | 62 } // namespace |
| 63 | 63 |
| 64 static std::unique_ptr<KeyedService> BuildSpellcheckService( | 64 static std::unique_ptr<KeyedService> BuildSpellcheckService( |
| 65 content::BrowserContext* profile) { | 65 content::BrowserContext* profile) { |
| 66 return base::WrapUnique( | 66 return base::MakeUnique<SpellcheckService>(static_cast<Profile*>(profile)); |
| 67 new SpellcheckService(static_cast<Profile*>(profile))); | |
| 68 } | 67 } |
| 69 | 68 |
| 70 class SpellcheckCustomDictionaryTest : public testing::Test { | 69 class SpellcheckCustomDictionaryTest : public testing::Test { |
| 71 protected: | 70 protected: |
| 72 void SetUp() override { | 71 void SetUp() override { |
| 73 // Use SetTestingFactoryAndUse to force creation and initialization. | 72 // Use SetTestingFactoryAndUse to force creation and initialization. |
| 74 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 73 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 75 &profile_, &BuildSpellcheckService); | 74 &profile_, &BuildSpellcheckService); |
| 76 | 75 |
| 77 StatisticsRecorder::Initialize(); | 76 StatisticsRecorder::Initialize(); |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 new syncer::SyncChangeProcessorWrapperForTest( | 903 new syncer::SyncChangeProcessorWrapperForTest( |
| 905 custom_dictionary2)), | 904 custom_dictionary2)), |
| 906 std::unique_ptr<syncer::SyncErrorFactory>( | 905 std::unique_ptr<syncer::SyncErrorFactory>( |
| 907 new SyncErrorFactoryStub(&error_counter))) | 906 new SyncErrorFactoryStub(&error_counter))) |
| 908 .error() | 907 .error() |
| 909 .IsSet()); | 908 .IsSet()); |
| 910 EXPECT_EQ(0, error_counter); | 909 EXPECT_EQ(0, error_counter); |
| 911 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 910 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
| 912 | 911 |
| 913 OnLoaded(*custom_dictionary, | 912 OnLoaded(*custom_dictionary, |
| 914 base::WrapUnique(new std::set<std::string>(change.to_add()))); | 913 base::MakeUnique<std::set<std::string>>(change.to_add())); |
| 915 EXPECT_EQ(0, error_counter); | 914 EXPECT_EQ(0, error_counter); |
| 916 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 915 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
| 917 | 916 |
| 918 EXPECT_EQ(spellcheck::MAX_SYNCABLE_DICTIONARY_WORDS / 2, | 917 EXPECT_EQ(spellcheck::MAX_SYNCABLE_DICTIONARY_WORDS / 2, |
| 919 custom_dictionary->GetWords().size()); | 918 custom_dictionary->GetWords().size()); |
| 920 EXPECT_EQ(spellcheck::MAX_SYNCABLE_DICTIONARY_WORDS / 2, | 919 EXPECT_EQ(spellcheck::MAX_SYNCABLE_DICTIONARY_WORDS / 2, |
| 921 custom_dictionary2->GetWords().size()); | 920 custom_dictionary2->GetWords().size()); |
| 922 | 921 |
| 923 EXPECT_EQ(spellcheck::MAX_SYNCABLE_DICTIONARY_WORDS / 2, | 922 EXPECT_EQ(spellcheck::MAX_SYNCABLE_DICTIONARY_WORDS / 2, |
| 924 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 923 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 SpellcheckServiceFactory::GetForContext(&profile_); | 1193 SpellcheckServiceFactory::GetForContext(&profile_); |
| 1195 SpellcheckCustomDictionary* custom_dictionary = | 1194 SpellcheckCustomDictionary* custom_dictionary = |
| 1196 spellcheck_service->GetCustomDictionary(); | 1195 spellcheck_service->GetCustomDictionary(); |
| 1197 OnLoaded(*custom_dictionary, base::WrapUnique(new std::set<std::string>)); | 1196 OnLoaded(*custom_dictionary, base::WrapUnique(new std::set<std::string>)); |
| 1198 EXPECT_FALSE(custom_dictionary->HasWord("foo")); | 1197 EXPECT_FALSE(custom_dictionary->HasWord("foo")); |
| 1199 EXPECT_FALSE(custom_dictionary->HasWord("bar")); | 1198 EXPECT_FALSE(custom_dictionary->HasWord("bar")); |
| 1200 custom_dictionary->AddWord("foo"); | 1199 custom_dictionary->AddWord("foo"); |
| 1201 EXPECT_TRUE(custom_dictionary->HasWord("foo")); | 1200 EXPECT_TRUE(custom_dictionary->HasWord("foo")); |
| 1202 EXPECT_FALSE(custom_dictionary->HasWord("bar")); | 1201 EXPECT_FALSE(custom_dictionary->HasWord("bar")); |
| 1203 } | 1202 } |
| OLD | NEW |