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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/metrics/histogram_samples.h" | 16 #include "base/metrics/histogram_samples.h" |
17 #include "base/metrics/statistics_recorder.h" | 17 #include "base/metrics/statistics_recorder.h" |
18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 21 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
22 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 22 #include "components/spellcheck/browser/spellcheck_host_metrics.h" |
| 23 #include "components/spellcheck/common/spellcheck_common.h" |
23 #include "chrome/browser/spellchecker/spellcheck_service.h" | 24 #include "chrome/browser/spellchecker/spellcheck_service.h" |
24 #include "chrome/common/chrome_constants.h" | 25 //#include "chrome/common/chrome_constants.h" |
25 #include "chrome/common/spellcheck_common.h" | 26 #include "components/spellcheck/common/spellcheck_common.h" |
26 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
27 #include "content/public/test/test_browser_thread_bundle.h" | 28 #include "content/public/test/test_browser_thread_bundle.h" |
28 #include "net/url_request/test_url_fetcher_factory.h" | 29 #include "net/url_request/test_url_fetcher_factory.h" |
29 #include "sync/api/sync_change.h" | 30 #include "sync/api/sync_change.h" |
30 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 31 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
31 #include "sync/api/sync_data.h" | 32 #include "sync/api/sync_data.h" |
32 #include "sync/api/sync_error_factory.h" | 33 #include "sync/api/sync_error_factory.h" |
33 #include "sync/api/sync_error_factory_mock.h" | 34 #include "sync/api/sync_error_factory_mock.h" |
34 #include "sync/protocol/sync.pb.h" | 35 #include "sync/protocol/sync.pb.h" |
35 #include "testing/gmock/include/gmock/gmock.h" | 36 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 164 } |
164 | 165 |
165 private: | 166 private: |
166 int loads_; | 167 int loads_; |
167 int changes_; | 168 int changes_; |
168 DISALLOW_COPY_AND_ASSIGN(DictionaryObserverCounter); | 169 DISALLOW_COPY_AND_ASSIGN(DictionaryObserverCounter); |
169 }; | 170 }; |
170 | 171 |
171 TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) { | 172 TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) { |
172 base::FilePath path = | 173 base::FilePath path = |
173 profile_.GetPath().Append(chrome::kCustomDictionaryFileName); | 174 profile_.GetPath().Append(SpellcheckCustomDictionary::kCustomDictionaryFil
eName); |
174 | 175 |
175 // The custom word list should be empty now. | 176 // The custom word list should be empty now. |
176 EXPECT_TRUE(LoadDictionaryFile(path)->words.empty()); | 177 EXPECT_TRUE(LoadDictionaryFile(path)->words.empty()); |
177 | 178 |
178 std::unique_ptr<SpellcheckCustomDictionary::Change> change( | 179 std::unique_ptr<SpellcheckCustomDictionary::Change> change( |
179 new SpellcheckCustomDictionary::Change); | 180 new SpellcheckCustomDictionary::Change); |
180 change->AddWord("bar"); | 181 change->AddWord("bar"); |
181 change->AddWord("foo"); | 182 change->AddWord("foo"); |
182 | 183 |
183 UpdateDictionaryFile(std::move(change), path); | 184 UpdateDictionaryFile(std::move(change), path); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 std::set<std::string> actual1 = custom_dictionary->GetWords(); | 226 std::set<std::string> actual1 = custom_dictionary->GetWords(); |
226 EXPECT_EQ(actual1, expected1); | 227 EXPECT_EQ(actual1, expected1); |
227 | 228 |
228 std::set<std::string> actual2 = custom_dictionary2->GetWords(); | 229 std::set<std::string> actual2 = custom_dictionary2->GetWords(); |
229 EXPECT_EQ(actual2, expected2); | 230 EXPECT_EQ(actual2, expected2); |
230 } | 231 } |
231 | 232 |
232 // Legacy empty dictionary should be converted to new format empty dictionary. | 233 // Legacy empty dictionary should be converted to new format empty dictionary. |
233 TEST_F(SpellcheckCustomDictionaryTest, LegacyEmptyDictionaryShouldBeConverted) { | 234 TEST_F(SpellcheckCustomDictionaryTest, LegacyEmptyDictionaryShouldBeConverted) { |
234 base::FilePath path = | 235 base::FilePath path = |
235 profile_.GetPath().Append(chrome::kCustomDictionaryFileName); | 236 profile_.GetPath().Append(SpellcheckCustomDictionary::kCustomDictionaryFil
eName); |
236 | 237 |
237 std::string content; | 238 std::string content; |
238 base::WriteFile(path, content.c_str(), content.length()); | 239 base::WriteFile(path, content.c_str(), content.length()); |
239 EXPECT_TRUE(LoadDictionaryFile(path)->words.empty()); | 240 EXPECT_TRUE(LoadDictionaryFile(path)->words.empty()); |
240 } | 241 } |
241 | 242 |
242 // Legacy dictionary with two words should be converted to new format dictionary | 243 // Legacy dictionary with two words should be converted to new format dictionary |
243 // with two words. | 244 // with two words. |
244 TEST_F(SpellcheckCustomDictionaryTest, | 245 TEST_F(SpellcheckCustomDictionaryTest, |
245 LegacyDictionaryWithTwoWordsShouldBeConverted) { | 246 LegacyDictionaryWithTwoWordsShouldBeConverted) { |
246 base::FilePath path = | 247 base::FilePath path = |
247 profile_.GetPath().Append(chrome::kCustomDictionaryFileName); | 248 profile_.GetPath().Append(SpellcheckCustomDictionary::kCustomDictionaryFil
eName); |
248 | 249 |
249 std::string content = "foo\nbar\nfoo\n"; | 250 std::string content = "foo\nbar\nfoo\n"; |
250 base::WriteFile(path, content.c_str(), content.length()); | 251 base::WriteFile(path, content.c_str(), content.length()); |
251 std::set<std::string> expected; | 252 std::set<std::string> expected; |
252 expected.insert("bar"); | 253 expected.insert("bar"); |
253 expected.insert("foo"); | 254 expected.insert("foo"); |
254 EXPECT_EQ(expected, LoadDictionaryFile(path)->words); | 255 EXPECT_EQ(expected, LoadDictionaryFile(path)->words); |
255 } | 256 } |
256 | 257 |
257 // Illegal words should be removed. Leading and trailing whitespace should be | 258 // Illegal words should be removed. Leading and trailing whitespace should be |
258 // trimmed. | 259 // trimmed. |
259 TEST_F(SpellcheckCustomDictionaryTest, | 260 TEST_F(SpellcheckCustomDictionaryTest, |
260 IllegalWordsShouldBeRemovedFromDictionary) { | 261 IllegalWordsShouldBeRemovedFromDictionary) { |
261 base::FilePath path = | 262 base::FilePath path = |
262 profile_.GetPath().Append(chrome::kCustomDictionaryFileName); | 263 profile_.GetPath().Append(SpellcheckCustomDictionary::kCustomDictionaryFil
eName); |
263 | 264 |
264 std::string content = "foo\n foo bar \n\n \nbar\n" | 265 std::string content = "foo\n foo bar \n\n \nbar\n" |
265 "01234567890123456789012345678901234567890123456789" | 266 "01234567890123456789012345678901234567890123456789" |
266 "01234567890123456789012345678901234567890123456789"; | 267 "01234567890123456789012345678901234567890123456789"; |
267 base::WriteFile(path, content.c_str(), content.length()); | 268 base::WriteFile(path, content.c_str(), content.length()); |
268 std::set<std::string> expected; | 269 std::set<std::string> expected; |
269 expected.insert("bar"); | 270 expected.insert("bar"); |
270 expected.insert("foo"); | 271 expected.insert("foo"); |
271 expected.insert("foo bar"); | 272 expected.insert("foo bar"); |
272 EXPECT_EQ(expected, LoadDictionaryFile(path)->words); | 273 EXPECT_EQ(expected, LoadDictionaryFile(path)->words); |
273 } | 274 } |
274 | 275 |
275 // Write to dictionary should backup previous version and write the word to the | 276 // Write to dictionary should backup previous version and write the word to the |
276 // end of the dictionary. If the dictionary file is corrupted on disk, the | 277 // end of the dictionary. If the dictionary file is corrupted on disk, the |
277 // previous version should be reloaded. | 278 // previous version should be reloaded. |
278 TEST_F(SpellcheckCustomDictionaryTest, CorruptedWriteShouldBeRecovered) { | 279 TEST_F(SpellcheckCustomDictionaryTest, CorruptedWriteShouldBeRecovered) { |
279 base::FilePath path = | 280 base::FilePath path = |
280 profile_.GetPath().Append(chrome::kCustomDictionaryFileName); | 281 profile_.GetPath().Append(SpellcheckCustomDictionary::kCustomDictionaryFil
eName); |
281 | 282 |
282 std::string content = "foo\nbar"; | 283 std::string content = "foo\nbar"; |
283 base::WriteFile(path, content.c_str(), content.length()); | 284 base::WriteFile(path, content.c_str(), content.length()); |
284 std::set<std::string> expected; | 285 std::set<std::string> expected; |
285 expected.insert("bar"); | 286 expected.insert("bar"); |
286 expected.insert("foo"); | 287 expected.insert("foo"); |
287 EXPECT_EQ(expected, LoadDictionaryFile(path)->words); | 288 EXPECT_EQ(expected, LoadDictionaryFile(path)->words); |
288 | 289 |
289 std::unique_ptr<SpellcheckCustomDictionary::Change> change( | 290 std::unique_ptr<SpellcheckCustomDictionary::Change> change( |
290 new SpellcheckCustomDictionary::Change); | 291 new SpellcheckCustomDictionary::Change); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 EXPECT_TRUE(data.empty()); | 329 EXPECT_TRUE(data.empty()); |
329 } | 330 } |
330 | 331 |
331 TEST_F(SpellcheckCustomDictionaryTest, GetAllSyncDataHasLimit) { | 332 TEST_F(SpellcheckCustomDictionaryTest, GetAllSyncDataHasLimit) { |
332 SpellcheckCustomDictionary* dictionary = | 333 SpellcheckCustomDictionary* dictionary = |
333 SpellcheckServiceFactory::GetForContext( | 334 SpellcheckServiceFactory::GetForContext( |
334 &profile_)->GetCustomDictionary(); | 335 &profile_)->GetCustomDictionary(); |
335 | 336 |
336 SpellcheckCustomDictionary::Change change; | 337 SpellcheckCustomDictionary::Change change; |
337 for (size_t i = 0; | 338 for (size_t i = 0; |
338 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; | 339 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; |
339 i++) { | 340 i++) { |
340 change.AddWord("foo" + base::Uint64ToString(i)); | 341 change.AddWord("foo" + base::Uint64ToString(i)); |
341 } | 342 } |
342 Apply(*dictionary, change); | 343 Apply(*dictionary, change); |
343 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1, | 344 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1, |
344 dictionary->GetWords().size()); | 345 dictionary->GetWords().size()); |
345 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1, | 346 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1, |
346 dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 347 dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
347 | 348 |
348 dictionary->AddWord("baz"); | 349 dictionary->AddWord("baz"); |
349 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 350 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
350 dictionary->GetWords().size()); | 351 dictionary->GetWords().size()); |
351 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 352 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
352 dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 353 dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
353 | 354 |
354 dictionary->AddWord("bar"); | 355 dictionary->AddWord("bar"); |
355 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 356 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
356 dictionary->GetWords().size()); | 357 dictionary->GetWords().size()); |
357 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 358 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
358 dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 359 dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
359 | 360 |
360 dictionary->AddWord("snafoo"); | 361 dictionary->AddWord("snafoo"); |
361 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 2, | 362 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 2, |
362 dictionary->GetWords().size()); | 363 dictionary->GetWords().size()); |
363 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 364 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
364 dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 365 dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
365 } | 366 } |
366 | 367 |
367 TEST_F(SpellcheckCustomDictionaryTest, ProcessSyncChanges) { | 368 TEST_F(SpellcheckCustomDictionaryTest, ProcessSyncChanges) { |
368 SpellcheckService* spellcheck_service = | 369 SpellcheckService* spellcheck_service = |
369 SpellcheckServiceFactory::GetForContext(&profile_); | 370 SpellcheckServiceFactory::GetForContext(&profile_); |
370 SpellcheckCustomDictionary* dictionary = | 371 SpellcheckCustomDictionary* dictionary = |
371 spellcheck_service->GetCustomDictionary(); | 372 spellcheck_service->GetCustomDictionary(); |
372 | 373 |
373 dictionary->AddWord("foo"); | 374 dictionary->AddWord("foo"); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 TestingProfile profile2; | 444 TestingProfile profile2; |
444 SpellcheckService* spellcheck_service2 = | 445 SpellcheckService* spellcheck_service2 = |
445 static_cast<SpellcheckService*>( | 446 static_cast<SpellcheckService*>( |
446 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 447 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
447 &profile2, &BuildSpellcheckService)); | 448 &profile2, &BuildSpellcheckService)); |
448 SpellcheckCustomDictionary* custom_dictionary2 = | 449 SpellcheckCustomDictionary* custom_dictionary2 = |
449 spellcheck_service2->GetCustomDictionary(); | 450 spellcheck_service2->GetCustomDictionary(); |
450 | 451 |
451 SpellcheckCustomDictionary::Change change; | 452 SpellcheckCustomDictionary::Change change; |
452 for (size_t i = 0; | 453 for (size_t i = 0; |
453 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; | 454 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; |
454 ++i) { | 455 ++i) { |
455 change.AddWord("foo" + base::Uint64ToString(i)); | 456 change.AddWord("foo" + base::Uint64ToString(i)); |
456 } | 457 } |
457 Apply(*custom_dictionary, change); | 458 Apply(*custom_dictionary, change); |
458 | 459 |
459 SpellcheckCustomDictionary::Change change2; | 460 SpellcheckCustomDictionary::Change change2; |
460 for (size_t i = 0; | 461 for (size_t i = 0; |
461 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; | 462 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; |
462 ++i) { | 463 ++i) { |
463 change2.AddWord("bar" + base::Uint64ToString(i)); | 464 change2.AddWord("bar" + base::Uint64ToString(i)); |
464 } | 465 } |
465 Apply(*custom_dictionary2, change2); | 466 Apply(*custom_dictionary2, change2); |
466 | 467 |
467 int error_counter = 0; | 468 int error_counter = 0; |
468 EXPECT_FALSE(custom_dictionary | 469 EXPECT_FALSE(custom_dictionary |
469 ->MergeDataAndStartSyncing( | 470 ->MergeDataAndStartSyncing( |
470 syncer::DICTIONARY, | 471 syncer::DICTIONARY, |
471 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 472 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), |
(...skipping 23 matching lines...) Expand all Loading... |
495 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 496 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
496 &profile2, &BuildSpellcheckService)) | 497 &profile2, &BuildSpellcheckService)) |
497 ->GetCustomDictionary(); | 498 ->GetCustomDictionary(); |
498 | 499 |
499 std::unique_ptr<SpellcheckCustomDictionary::Change> change( | 500 std::unique_ptr<SpellcheckCustomDictionary::Change> change( |
500 new SpellcheckCustomDictionary::Change); | 501 new SpellcheckCustomDictionary::Change); |
501 change->AddWord("foo"); | 502 change->AddWord("foo"); |
502 Apply(*custom_dictionary2, *change); | 503 Apply(*custom_dictionary2, *change); |
503 | 504 |
504 base::FilePath path = | 505 base::FilePath path = |
505 profile_.GetPath().Append(chrome::kCustomDictionaryFileName); | 506 profile_.GetPath().Append(SpellcheckCustomDictionary::kCustomDictionaryFil
eName); |
506 UpdateDictionaryFile(std::move(change), path); | 507 UpdateDictionaryFile(std::move(change), path); |
507 EXPECT_TRUE(custom_dictionary->GetWords().empty()); | 508 EXPECT_TRUE(custom_dictionary->GetWords().empty()); |
508 | 509 |
509 int error_counter = 0; | 510 int error_counter = 0; |
510 EXPECT_FALSE(custom_dictionary | 511 EXPECT_FALSE(custom_dictionary |
511 ->MergeDataAndStartSyncing( | 512 ->MergeDataAndStartSyncing( |
512 syncer::DICTIONARY, | 513 syncer::DICTIONARY, |
513 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 514 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), |
514 std::unique_ptr<syncer::SyncChangeProcessor>( | 515 std::unique_ptr<syncer::SyncChangeProcessor>( |
515 new syncer::SyncChangeProcessorWrapperForTest( | 516 new syncer::SyncChangeProcessorWrapperForTest( |
(...skipping 28 matching lines...) Expand all Loading... |
544 TestingProfile profile2; | 545 TestingProfile profile2; |
545 SpellcheckService* spellcheck_service2 = | 546 SpellcheckService* spellcheck_service2 = |
546 static_cast<SpellcheckService*>( | 547 static_cast<SpellcheckService*>( |
547 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 548 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
548 &profile2, &BuildSpellcheckService)); | 549 &profile2, &BuildSpellcheckService)); |
549 SpellcheckCustomDictionary* custom_dictionary2 = | 550 SpellcheckCustomDictionary* custom_dictionary2 = |
550 spellcheck_service2->GetCustomDictionary(); | 551 spellcheck_service2->GetCustomDictionary(); |
551 | 552 |
552 SpellcheckCustomDictionary::Change change; | 553 SpellcheckCustomDictionary::Change change; |
553 for (size_t i = 0; | 554 for (size_t i = 0; |
554 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1; | 555 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1; |
555 ++i) { | 556 ++i) { |
556 change.AddWord("foo" + base::Uint64ToString(i)); | 557 change.AddWord("foo" + base::Uint64ToString(i)); |
557 } | 558 } |
558 Apply(*custom_dictionary, change); | 559 Apply(*custom_dictionary, change); |
559 | 560 |
560 int error_counter = 0; | 561 int error_counter = 0; |
561 EXPECT_FALSE(custom_dictionary | 562 EXPECT_FALSE(custom_dictionary |
562 ->MergeDataAndStartSyncing( | 563 ->MergeDataAndStartSyncing( |
563 syncer::DICTIONARY, | 564 syncer::DICTIONARY, |
564 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 565 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), |
565 std::unique_ptr<syncer::SyncChangeProcessor>( | 566 std::unique_ptr<syncer::SyncChangeProcessor>( |
566 new syncer::SyncChangeProcessorWrapperForTest( | 567 new syncer::SyncChangeProcessorWrapperForTest( |
567 custom_dictionary2)), | 568 custom_dictionary2)), |
568 std::unique_ptr<syncer::SyncErrorFactory>( | 569 std::unique_ptr<syncer::SyncErrorFactory>( |
569 new SyncErrorFactoryStub(&error_counter))) | 570 new SyncErrorFactoryStub(&error_counter))) |
570 .error() | 571 .error() |
571 .IsSet()); | 572 .IsSet()); |
572 EXPECT_EQ(0, error_counter); | 573 EXPECT_EQ(0, error_counter); |
573 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 574 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
574 | 575 |
575 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 576 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
576 custom_dictionary->GetWords().size()); | 577 custom_dictionary->GetWords().size()); |
577 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 578 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
578 custom_dictionary2->GetWords().size()); | 579 custom_dictionary2->GetWords().size()); |
579 | 580 |
580 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 581 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
581 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 582 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
582 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 583 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
583 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); | 584 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); |
584 } | 585 } |
585 | 586 |
586 TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigAndServerFull) { | 587 TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigAndServerFull) { |
587 SpellcheckService* spellcheck_service = | 588 SpellcheckService* spellcheck_service = |
588 SpellcheckServiceFactory::GetForContext(&profile_); | 589 SpellcheckServiceFactory::GetForContext(&profile_); |
589 SpellcheckCustomDictionary* custom_dictionary = | 590 SpellcheckCustomDictionary* custom_dictionary = |
590 spellcheck_service->GetCustomDictionary(); | 591 spellcheck_service->GetCustomDictionary(); |
591 TestingProfile profile2; | 592 TestingProfile profile2; |
592 SpellcheckService* spellcheck_service2 = | 593 SpellcheckService* spellcheck_service2 = |
593 static_cast<SpellcheckService*>( | 594 static_cast<SpellcheckService*>( |
594 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 595 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
595 &profile2, &BuildSpellcheckService)); | 596 &profile2, &BuildSpellcheckService)); |
596 SpellcheckCustomDictionary* custom_dictionary2 = | 597 SpellcheckCustomDictionary* custom_dictionary2 = |
597 spellcheck_service2->GetCustomDictionary(); | 598 spellcheck_service2->GetCustomDictionary(); |
598 | 599 |
599 SpellcheckCustomDictionary::Change change; | 600 SpellcheckCustomDictionary::Change change; |
600 SpellcheckCustomDictionary::Change change2; | 601 SpellcheckCustomDictionary::Change change2; |
601 for (size_t i = 0; | 602 for (size_t i = 0; |
602 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; | 603 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; |
603 ++i) { | 604 ++i) { |
604 change.AddWord("foo" + base::Uint64ToString(i)); | 605 change.AddWord("foo" + base::Uint64ToString(i)); |
605 change2.AddWord("bar" + base::Uint64ToString(i)); | 606 change2.AddWord("bar" + base::Uint64ToString(i)); |
606 } | 607 } |
607 change.AddWord("foo"); | 608 change.AddWord("foo"); |
608 Apply(*custom_dictionary, change); | 609 Apply(*custom_dictionary, change); |
609 Apply(*custom_dictionary2, change2); | 610 Apply(*custom_dictionary2, change2); |
610 | 611 |
611 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 612 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
612 custom_dictionary->GetWords().size()); | 613 custom_dictionary->GetWords().size()); |
613 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 614 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
614 custom_dictionary2->GetWords().size()); | 615 custom_dictionary2->GetWords().size()); |
615 | 616 |
616 int error_counter = 0; | 617 int error_counter = 0; |
617 EXPECT_FALSE(custom_dictionary | 618 EXPECT_FALSE(custom_dictionary |
618 ->MergeDataAndStartSyncing( | 619 ->MergeDataAndStartSyncing( |
619 syncer::DICTIONARY, | 620 syncer::DICTIONARY, |
620 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 621 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), |
621 std::unique_ptr<syncer::SyncChangeProcessor>( | 622 std::unique_ptr<syncer::SyncChangeProcessor>( |
622 new syncer::SyncChangeProcessorWrapperForTest( | 623 new syncer::SyncChangeProcessorWrapperForTest( |
623 custom_dictionary2)), | 624 custom_dictionary2)), |
624 std::unique_ptr<syncer::SyncErrorFactory>( | 625 std::unique_ptr<syncer::SyncErrorFactory>( |
625 new SyncErrorFactoryStub(&error_counter))) | 626 new SyncErrorFactoryStub(&error_counter))) |
626 .error() | 627 .error() |
627 .IsSet()); | 628 .IsSet()); |
628 EXPECT_EQ(0, error_counter); | 629 EXPECT_EQ(0, error_counter); |
629 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 630 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
630 | 631 |
631 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2 + 1, | 632 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2 + 1, |
632 custom_dictionary->GetWords().size()); | 633 custom_dictionary->GetWords().size()); |
633 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 634 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
634 custom_dictionary2->GetWords().size()); | 635 custom_dictionary2->GetWords().size()); |
635 | 636 |
636 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 637 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
637 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 638 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
638 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 639 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
639 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); | 640 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); |
640 } | 641 } |
641 | 642 |
642 TEST_F(SpellcheckCustomDictionaryTest, ServerTooBig) { | 643 TEST_F(SpellcheckCustomDictionaryTest, ServerTooBig) { |
643 SpellcheckService* spellcheck_service = | 644 SpellcheckService* spellcheck_service = |
644 SpellcheckServiceFactory::GetForContext(&profile_); | 645 SpellcheckServiceFactory::GetForContext(&profile_); |
645 SpellcheckCustomDictionary* custom_dictionary = | 646 SpellcheckCustomDictionary* custom_dictionary = |
646 spellcheck_service->GetCustomDictionary(); | 647 spellcheck_service->GetCustomDictionary(); |
647 TestingProfile profile2; | 648 TestingProfile profile2; |
648 SpellcheckService* spellcheck_service2 = | 649 SpellcheckService* spellcheck_service2 = |
649 static_cast<SpellcheckService*>( | 650 static_cast<SpellcheckService*>( |
650 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 651 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
651 &profile2, &BuildSpellcheckService)); | 652 &profile2, &BuildSpellcheckService)); |
652 SpellcheckCustomDictionary* custom_dictionary2 = | 653 SpellcheckCustomDictionary* custom_dictionary2 = |
653 spellcheck_service2->GetCustomDictionary(); | 654 spellcheck_service2->GetCustomDictionary(); |
654 | 655 |
655 SpellcheckCustomDictionary::Change change; | 656 SpellcheckCustomDictionary::Change change; |
656 SpellcheckCustomDictionary::Change change2; | 657 SpellcheckCustomDictionary::Change change2; |
657 for (size_t i = 0; | 658 for (size_t i = 0; |
658 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1; | 659 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1; |
659 ++i) { | 660 ++i) { |
660 change.AddWord("foo" + base::Uint64ToString(i)); | 661 change.AddWord("foo" + base::Uint64ToString(i)); |
661 change2.AddWord("bar" + base::Uint64ToString(i)); | 662 change2.AddWord("bar" + base::Uint64ToString(i)); |
662 } | 663 } |
663 Apply(*custom_dictionary, change); | 664 Apply(*custom_dictionary, change); |
664 Apply(*custom_dictionary2, change2); | 665 Apply(*custom_dictionary2, change2); |
665 | 666 |
666 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 667 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
667 custom_dictionary->GetWords().size()); | 668 custom_dictionary->GetWords().size()); |
668 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 669 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
669 custom_dictionary2->GetWords().size()); | 670 custom_dictionary2->GetWords().size()); |
670 | 671 |
671 int error_counter = 0; | 672 int error_counter = 0; |
672 EXPECT_FALSE(custom_dictionary | 673 EXPECT_FALSE(custom_dictionary |
673 ->MergeDataAndStartSyncing( | 674 ->MergeDataAndStartSyncing( |
674 syncer::DICTIONARY, | 675 syncer::DICTIONARY, |
675 GetAllSyncDataNoLimit(custom_dictionary2), | 676 GetAllSyncDataNoLimit(custom_dictionary2), |
676 std::unique_ptr<syncer::SyncChangeProcessor>( | 677 std::unique_ptr<syncer::SyncChangeProcessor>( |
677 new syncer::SyncChangeProcessorWrapperForTest( | 678 new syncer::SyncChangeProcessorWrapperForTest( |
678 custom_dictionary2)), | 679 custom_dictionary2)), |
679 std::unique_ptr<syncer::SyncErrorFactory>( | 680 std::unique_ptr<syncer::SyncErrorFactory>( |
680 new SyncErrorFactoryStub(&error_counter))) | 681 new SyncErrorFactoryStub(&error_counter))) |
681 .error() | 682 .error() |
682 .IsSet()); | 683 .IsSet()); |
683 EXPECT_EQ(0, error_counter); | 684 EXPECT_EQ(0, error_counter); |
684 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 685 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
685 | 686 |
686 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2 + 2, | 687 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2 + 2, |
687 custom_dictionary->GetWords().size()); | 688 custom_dictionary->GetWords().size()); |
688 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 689 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
689 custom_dictionary2->GetWords().size()); | 690 custom_dictionary2->GetWords().size()); |
690 | 691 |
691 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 692 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
692 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 693 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
693 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 694 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
694 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); | 695 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); |
695 } | 696 } |
696 | 697 |
697 TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToStartSyncing) { | 698 TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToStartSyncing) { |
698 SpellcheckService* spellcheck_service = | 699 SpellcheckService* spellcheck_service = |
699 SpellcheckServiceFactory::GetForContext(&profile_); | 700 SpellcheckServiceFactory::GetForContext(&profile_); |
700 SpellcheckCustomDictionary* custom_dictionary = | 701 SpellcheckCustomDictionary* custom_dictionary = |
701 spellcheck_service->GetCustomDictionary(); | 702 spellcheck_service->GetCustomDictionary(); |
702 TestingProfile profile2; | 703 TestingProfile profile2; |
703 SpellcheckService* spellcheck_service2 = | 704 SpellcheckService* spellcheck_service2 = |
704 static_cast<SpellcheckService*>( | 705 static_cast<SpellcheckService*>( |
705 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 706 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
706 &profile2, &BuildSpellcheckService)); | 707 &profile2, &BuildSpellcheckService)); |
707 SpellcheckCustomDictionary* custom_dictionary2 = | 708 SpellcheckCustomDictionary* custom_dictionary2 = |
708 spellcheck_service2->GetCustomDictionary(); | 709 spellcheck_service2->GetCustomDictionary(); |
709 | 710 |
710 SpellcheckCustomDictionary::Change change; | 711 SpellcheckCustomDictionary::Change change; |
711 for (size_t i = 0; | 712 for (size_t i = 0; |
712 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; | 713 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; |
713 ++i) { | 714 ++i) { |
714 change.AddWord("foo" + base::Uint64ToString(i)); | 715 change.AddWord("foo" + base::Uint64ToString(i)); |
715 } | 716 } |
716 Apply(*custom_dictionary, change); | 717 Apply(*custom_dictionary, change); |
717 | 718 |
718 custom_dictionary2->AddWord("bar"); | 719 custom_dictionary2->AddWord("bar"); |
719 custom_dictionary2->AddWord("baz"); | 720 custom_dictionary2->AddWord("baz"); |
720 | 721 |
721 int error_counter = 0; | 722 int error_counter = 0; |
722 EXPECT_FALSE(custom_dictionary | 723 EXPECT_FALSE(custom_dictionary |
723 ->MergeDataAndStartSyncing( | 724 ->MergeDataAndStartSyncing( |
724 syncer::DICTIONARY, | 725 syncer::DICTIONARY, |
725 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 726 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), |
726 std::unique_ptr<syncer::SyncChangeProcessor>( | 727 std::unique_ptr<syncer::SyncChangeProcessor>( |
727 new syncer::SyncChangeProcessorWrapperForTest( | 728 new syncer::SyncChangeProcessorWrapperForTest( |
728 custom_dictionary2)), | 729 custom_dictionary2)), |
729 std::unique_ptr<syncer::SyncErrorFactory>( | 730 std::unique_ptr<syncer::SyncErrorFactory>( |
730 new SyncErrorFactoryStub(&error_counter))) | 731 new SyncErrorFactoryStub(&error_counter))) |
731 .error() | 732 .error() |
732 .IsSet()); | 733 .IsSet()); |
733 EXPECT_EQ(0, error_counter); | 734 EXPECT_EQ(0, error_counter); |
734 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 735 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
735 | 736 |
736 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 737 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
737 custom_dictionary->GetWords().size()); | 738 custom_dictionary->GetWords().size()); |
738 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 739 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
739 custom_dictionary2->GetWords().size()); | 740 custom_dictionary2->GetWords().size()); |
740 | 741 |
741 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 742 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
742 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 743 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
743 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 744 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
744 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); | 745 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); |
745 } | 746 } |
746 | 747 |
747 TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToContiueSyncing) { | 748 TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigToContiueSyncing) { |
748 SpellcheckService* spellcheck_service = | 749 SpellcheckService* spellcheck_service = |
749 SpellcheckServiceFactory::GetForContext(&profile_); | 750 SpellcheckServiceFactory::GetForContext(&profile_); |
750 SpellcheckCustomDictionary* custom_dictionary = | 751 SpellcheckCustomDictionary* custom_dictionary = |
751 spellcheck_service->GetCustomDictionary(); | 752 spellcheck_service->GetCustomDictionary(); |
752 TestingProfile profile2; | 753 TestingProfile profile2; |
753 SpellcheckService* spellcheck_service2 = | 754 SpellcheckService* spellcheck_service2 = |
754 static_cast<SpellcheckService*>( | 755 static_cast<SpellcheckService*>( |
755 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 756 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
756 &profile2, &BuildSpellcheckService)); | 757 &profile2, &BuildSpellcheckService)); |
757 SpellcheckCustomDictionary* custom_dictionary2 = | 758 SpellcheckCustomDictionary* custom_dictionary2 = |
758 spellcheck_service2->GetCustomDictionary(); | 759 spellcheck_service2->GetCustomDictionary(); |
759 | 760 |
760 SpellcheckCustomDictionary::Change change; | 761 SpellcheckCustomDictionary::Change change; |
761 for (size_t i = 0; | 762 for (size_t i = 0; |
762 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; | 763 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; |
763 ++i) { | 764 ++i) { |
764 change.AddWord("foo" + base::Uint64ToString(i)); | 765 change.AddWord("foo" + base::Uint64ToString(i)); |
765 } | 766 } |
766 Apply(*custom_dictionary, change); | 767 Apply(*custom_dictionary, change); |
767 | 768 |
768 int error_counter = 0; | 769 int error_counter = 0; |
769 EXPECT_FALSE(custom_dictionary | 770 EXPECT_FALSE(custom_dictionary |
770 ->MergeDataAndStartSyncing( | 771 ->MergeDataAndStartSyncing( |
771 syncer::DICTIONARY, | 772 syncer::DICTIONARY, |
772 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 773 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), |
773 std::unique_ptr<syncer::SyncChangeProcessor>( | 774 std::unique_ptr<syncer::SyncChangeProcessor>( |
774 new syncer::SyncChangeProcessorWrapperForTest( | 775 new syncer::SyncChangeProcessorWrapperForTest( |
775 custom_dictionary2)), | 776 custom_dictionary2)), |
776 std::unique_ptr<syncer::SyncErrorFactory>( | 777 std::unique_ptr<syncer::SyncErrorFactory>( |
777 new SyncErrorFactoryStub(&error_counter))) | 778 new SyncErrorFactoryStub(&error_counter))) |
778 .error() | 779 .error() |
779 .IsSet()); | 780 .IsSet()); |
780 EXPECT_EQ(0, error_counter); | 781 EXPECT_EQ(0, error_counter); |
781 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 782 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
782 | 783 |
783 custom_dictionary->AddWord("bar"); | 784 custom_dictionary->AddWord("bar"); |
784 EXPECT_EQ(0, error_counter); | 785 EXPECT_EQ(0, error_counter); |
785 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 786 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
786 | 787 |
787 custom_dictionary->AddWord("baz"); | 788 custom_dictionary->AddWord("baz"); |
788 EXPECT_EQ(0, error_counter); | 789 EXPECT_EQ(0, error_counter); |
789 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 790 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
790 | 791 |
791 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 792 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
792 custom_dictionary->GetWords().size()); | 793 custom_dictionary->GetWords().size()); |
793 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 794 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
794 custom_dictionary2->GetWords().size()); | 795 custom_dictionary2->GetWords().size()); |
795 | 796 |
796 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 797 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
797 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 798 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
798 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 799 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
799 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); | 800 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); |
800 } | 801 } |
801 | 802 |
802 TEST_F(SpellcheckCustomDictionaryTest, LoadAfterSyncStart) { | 803 TEST_F(SpellcheckCustomDictionaryTest, LoadAfterSyncStart) { |
803 SpellcheckService* spellcheck_service = | 804 SpellcheckService* spellcheck_service = |
804 SpellcheckServiceFactory::GetForContext(&profile_); | 805 SpellcheckServiceFactory::GetForContext(&profile_); |
805 SpellcheckCustomDictionary* custom_dictionary = | 806 SpellcheckCustomDictionary* custom_dictionary = |
806 spellcheck_service->GetCustomDictionary(); | 807 spellcheck_service->GetCustomDictionary(); |
807 TestingProfile profile2; | 808 TestingProfile profile2; |
808 SpellcheckService* spellcheck_service2 = | 809 SpellcheckService* spellcheck_service2 = |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 std::unique_ptr<syncer::SyncErrorFactory>( | 869 std::unique_ptr<syncer::SyncErrorFactory>( |
869 new SyncErrorFactoryStub(&error_counter))) | 870 new SyncErrorFactoryStub(&error_counter))) |
870 .error() | 871 .error() |
871 .IsSet()); | 872 .IsSet()); |
872 EXPECT_EQ(0, error_counter); | 873 EXPECT_EQ(0, error_counter); |
873 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 874 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
874 | 875 |
875 std::unique_ptr<std::set<std::string>> custom_words( | 876 std::unique_ptr<std::set<std::string>> custom_words( |
876 new std::set<std::string>); | 877 new std::set<std::string>); |
877 for (size_t i = 0; | 878 for (size_t i = 0; |
878 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; | 879 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; |
879 ++i) { | 880 ++i) { |
880 custom_words->insert(custom_words->end(), "foo" + base::Uint64ToString(i)); | 881 custom_words->insert(custom_words->end(), "foo" + base::Uint64ToString(i)); |
881 } | 882 } |
882 OnLoaded(*custom_dictionary, std::move(custom_words)); | 883 OnLoaded(*custom_dictionary, std::move(custom_words)); |
883 EXPECT_EQ(0, error_counter); | 884 EXPECT_EQ(0, error_counter); |
884 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 885 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
885 | 886 |
886 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 887 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
887 custom_dictionary->GetWords().size()); | 888 custom_dictionary->GetWords().size()); |
888 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 889 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
889 custom_dictionary2->GetWords().size()); | 890 custom_dictionary2->GetWords().size()); |
890 | 891 |
891 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 892 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
892 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 893 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
893 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 894 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
894 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); | 895 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); |
895 } | 896 } |
896 | 897 |
897 TEST_F(SpellcheckCustomDictionaryTest, LoadDuplicatesAfterSync) { | 898 TEST_F(SpellcheckCustomDictionaryTest, LoadDuplicatesAfterSync) { |
898 SpellcheckService* spellcheck_service = | 899 SpellcheckService* spellcheck_service = |
899 SpellcheckServiceFactory::GetForContext(&profile_); | 900 SpellcheckServiceFactory::GetForContext(&profile_); |
900 SpellcheckCustomDictionary* custom_dictionary = | 901 SpellcheckCustomDictionary* custom_dictionary = |
901 spellcheck_service->GetCustomDictionary(); | 902 spellcheck_service->GetCustomDictionary(); |
902 TestingProfile profile2; | 903 TestingProfile profile2; |
903 SpellcheckService* spellcheck_service2 = | 904 SpellcheckService* spellcheck_service2 = |
904 static_cast<SpellcheckService*>( | 905 static_cast<SpellcheckService*>( |
905 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 906 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
906 &profile2, &BuildSpellcheckService)); | 907 &profile2, &BuildSpellcheckService)); |
907 SpellcheckCustomDictionary* custom_dictionary2 = | 908 SpellcheckCustomDictionary* custom_dictionary2 = |
908 spellcheck_service2->GetCustomDictionary(); | 909 spellcheck_service2->GetCustomDictionary(); |
909 | 910 |
910 SpellcheckCustomDictionary::Change change; | 911 SpellcheckCustomDictionary::Change change; |
911 for (size_t i = 0; | 912 for (size_t i = 0; |
912 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; | 913 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; |
913 ++i) { | 914 ++i) { |
914 change.AddWord("foo" + base::Uint64ToString(i)); | 915 change.AddWord("foo" + base::Uint64ToString(i)); |
915 } | 916 } |
916 Apply(*custom_dictionary, change); | 917 Apply(*custom_dictionary, change); |
917 | 918 |
918 int error_counter = 0; | 919 int error_counter = 0; |
919 EXPECT_FALSE(custom_dictionary | 920 EXPECT_FALSE(custom_dictionary |
920 ->MergeDataAndStartSyncing( | 921 ->MergeDataAndStartSyncing( |
921 syncer::DICTIONARY, | 922 syncer::DICTIONARY, |
922 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 923 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), |
923 std::unique_ptr<syncer::SyncChangeProcessor>( | 924 std::unique_ptr<syncer::SyncChangeProcessor>( |
924 new syncer::SyncChangeProcessorWrapperForTest( | 925 new syncer::SyncChangeProcessorWrapperForTest( |
925 custom_dictionary2)), | 926 custom_dictionary2)), |
926 std::unique_ptr<syncer::SyncErrorFactory>( | 927 std::unique_ptr<syncer::SyncErrorFactory>( |
927 new SyncErrorFactoryStub(&error_counter))) | 928 new SyncErrorFactoryStub(&error_counter))) |
928 .error() | 929 .error() |
929 .IsSet()); | 930 .IsSet()); |
930 EXPECT_EQ(0, error_counter); | 931 EXPECT_EQ(0, error_counter); |
931 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 932 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
932 | 933 |
933 OnLoaded(*custom_dictionary, | 934 OnLoaded(*custom_dictionary, |
934 base::WrapUnique(new std::set<std::string>(change.to_add()))); | 935 base::WrapUnique(new std::set<std::string>(change.to_add()))); |
935 EXPECT_EQ(0, error_counter); | 936 EXPECT_EQ(0, error_counter); |
936 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 937 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
937 | 938 |
938 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, | 939 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, |
939 custom_dictionary->GetWords().size()); | 940 custom_dictionary->GetWords().size()); |
940 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, | 941 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, |
941 custom_dictionary2->GetWords().size()); | 942 custom_dictionary2->GetWords().size()); |
942 | 943 |
943 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, | 944 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, |
944 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 945 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
945 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, | 946 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, |
946 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); | 947 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY).size()); |
947 } | 948 } |
948 | 949 |
949 TEST_F(SpellcheckCustomDictionaryTest, DictionaryLoadNotification) { | 950 TEST_F(SpellcheckCustomDictionaryTest, DictionaryLoadNotification) { |
950 SpellcheckService* spellcheck_service = | 951 SpellcheckService* spellcheck_service = |
951 SpellcheckServiceFactory::GetForContext(&profile_); | 952 SpellcheckServiceFactory::GetForContext(&profile_); |
952 SpellcheckCustomDictionary* custom_dictionary = | 953 SpellcheckCustomDictionary* custom_dictionary = |
953 spellcheck_service->GetCustomDictionary(); | 954 spellcheck_service->GetCustomDictionary(); |
954 | 955 |
955 DictionaryObserverCounter observer; | 956 DictionaryObserverCounter observer; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 | 1078 |
1078 // Upload the maximum number of words to the sync server. | 1079 // Upload the maximum number of words to the sync server. |
1079 { | 1080 { |
1080 SpellcheckService* spellcheck_service = | 1081 SpellcheckService* spellcheck_service = |
1081 SpellcheckServiceFactory::GetForContext(&profile_); | 1082 SpellcheckServiceFactory::GetForContext(&profile_); |
1082 SpellcheckCustomDictionary* custom_dictionary = | 1083 SpellcheckCustomDictionary* custom_dictionary = |
1083 spellcheck_service->GetCustomDictionary(); | 1084 spellcheck_service->GetCustomDictionary(); |
1084 | 1085 |
1085 SpellcheckCustomDictionary::Change change; | 1086 SpellcheckCustomDictionary::Change change; |
1086 for (size_t i = 0; | 1087 for (size_t i = 0; |
1087 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; | 1088 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; |
1088 ++i) { | 1089 ++i) { |
1089 change.AddWord("foo" + base::Uint64ToString(i)); | 1090 change.AddWord("foo" + base::Uint64ToString(i)); |
1090 } | 1091 } |
1091 Apply(*custom_dictionary, change); | 1092 Apply(*custom_dictionary, change); |
1092 | 1093 |
1093 int error_counter = 0; | 1094 int error_counter = 0; |
1094 EXPECT_FALSE( | 1095 EXPECT_FALSE( |
1095 custom_dictionary | 1096 custom_dictionary |
1096 ->MergeDataAndStartSyncing( | 1097 ->MergeDataAndStartSyncing( |
1097 syncer::DICTIONARY, | 1098 syncer::DICTIONARY, |
1098 server_custom_dictionary->GetAllSyncData(syncer::DICTIONARY), | 1099 server_custom_dictionary->GetAllSyncData(syncer::DICTIONARY), |
1099 std::unique_ptr<syncer::SyncChangeProcessor>( | 1100 std::unique_ptr<syncer::SyncChangeProcessor>( |
1100 new syncer::SyncChangeProcessorWrapperForTest( | 1101 new syncer::SyncChangeProcessorWrapperForTest( |
1101 server_custom_dictionary)), | 1102 server_custom_dictionary)), |
1102 std::unique_ptr<syncer::SyncErrorFactory>( | 1103 std::unique_ptr<syncer::SyncErrorFactory>( |
1103 new SyncErrorFactoryStub(&error_counter))) | 1104 new SyncErrorFactoryStub(&error_counter))) |
1104 .error() | 1105 .error() |
1105 .IsSet()); | 1106 .IsSet()); |
1106 EXPECT_EQ(0, error_counter); | 1107 EXPECT_EQ(0, error_counter); |
1107 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 1108 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
1108 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 1109 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
1109 custom_dictionary->GetWords().size()); | 1110 custom_dictionary->GetWords().size()); |
1110 } | 1111 } |
1111 | 1112 |
1112 // The sync server now has the maximum number of words. | 1113 // The sync server now has the maximum number of words. |
1113 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 1114 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
1114 server_custom_dictionary->GetWords().size()); | 1115 server_custom_dictionary->GetWords().size()); |
1115 | 1116 |
1116 // Associate the sync server with a client that also has the maximum number of | 1117 // Associate the sync server with a client that also has the maximum number of |
1117 // words, but all of these words are different from the ones on the sync | 1118 // words, but all of these words are different from the ones on the sync |
1118 // server. | 1119 // server. |
1119 { | 1120 { |
1120 TestingProfile client_profile; | 1121 TestingProfile client_profile; |
1121 SpellcheckService* client_spellcheck_service = | 1122 SpellcheckService* client_spellcheck_service = |
1122 static_cast<SpellcheckService*>( | 1123 static_cast<SpellcheckService*>( |
1123 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 1124 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
1124 &client_profile, &BuildSpellcheckService)); | 1125 &client_profile, &BuildSpellcheckService)); |
1125 | 1126 |
1126 // Here, |client_custom_dictionary| plays the role of the client. | 1127 // Here, |client_custom_dictionary| plays the role of the client. |
1127 SpellcheckCustomDictionary* client_custom_dictionary = | 1128 SpellcheckCustomDictionary* client_custom_dictionary = |
1128 client_spellcheck_service->GetCustomDictionary(); | 1129 client_spellcheck_service->GetCustomDictionary(); |
1129 | 1130 |
1130 // Add the maximum number of words to the client. These words are all | 1131 // Add the maximum number of words to the client. These words are all |
1131 // different from those on the server. | 1132 // different from those on the server. |
1132 SpellcheckCustomDictionary::Change change; | 1133 SpellcheckCustomDictionary::Change change; |
1133 for (size_t i = 0; | 1134 for (size_t i = 0; |
1134 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; | 1135 i < spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; |
1135 ++i) { | 1136 ++i) { |
1136 change.AddWord("bar" + base::Uint64ToString(i)); | 1137 change.AddWord("bar" + base::Uint64ToString(i)); |
1137 } | 1138 } |
1138 Apply(*client_custom_dictionary, change); | 1139 Apply(*client_custom_dictionary, change); |
1139 | 1140 |
1140 // Associate the server and the client. | 1141 // Associate the server and the client. |
1141 int error_counter = 0; | 1142 int error_counter = 0; |
1142 EXPECT_FALSE( | 1143 EXPECT_FALSE( |
1143 client_custom_dictionary | 1144 client_custom_dictionary |
1144 ->MergeDataAndStartSyncing( | 1145 ->MergeDataAndStartSyncing( |
1145 syncer::DICTIONARY, | 1146 syncer::DICTIONARY, |
1146 server_custom_dictionary->GetAllSyncData(syncer::DICTIONARY), | 1147 server_custom_dictionary->GetAllSyncData(syncer::DICTIONARY), |
1147 std::unique_ptr<syncer::SyncChangeProcessor>( | 1148 std::unique_ptr<syncer::SyncChangeProcessor>( |
1148 new syncer::SyncChangeProcessorWrapperForTest( | 1149 new syncer::SyncChangeProcessorWrapperForTest( |
1149 server_custom_dictionary)), | 1150 server_custom_dictionary)), |
1150 std::unique_ptr<syncer::SyncErrorFactory>( | 1151 std::unique_ptr<syncer::SyncErrorFactory>( |
1151 new SyncErrorFactoryStub(&error_counter))) | 1152 new SyncErrorFactoryStub(&error_counter))) |
1152 .error() | 1153 .error() |
1153 .IsSet()); | 1154 .IsSet()); |
1154 EXPECT_EQ(0, error_counter); | 1155 EXPECT_EQ(0, error_counter); |
1155 EXPECT_FALSE(client_custom_dictionary->IsSyncing()); | 1156 EXPECT_FALSE(client_custom_dictionary->IsSyncing()); |
1156 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2, | 1157 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2, |
1157 client_custom_dictionary->GetWords().size()); | 1158 client_custom_dictionary->GetWords().size()); |
1158 } | 1159 } |
1159 | 1160 |
1160 // The sync server should not receive more words, because it has the maximum | 1161 // The sync server should not receive more words, because it has the maximum |
1161 // number of words already. | 1162 // number of words already. |
1162 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 1163 EXPECT_EQ(spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
1163 server_custom_dictionary->GetWords().size()); | 1164 server_custom_dictionary->GetWords().size()); |
1164 } | 1165 } |
1165 | 1166 |
1166 TEST_F(SpellcheckCustomDictionaryTest, RecordSizeStatsCorrectly) { | 1167 TEST_F(SpellcheckCustomDictionaryTest, RecordSizeStatsCorrectly) { |
1167 #if defined(OS_WIN) | 1168 #if defined(OS_WIN) |
1168 // Failing consistently on Win7. See crbug.com/230534. | 1169 // Failing consistently on Win7. See crbug.com/230534. |
1169 if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 1170 if (base::win::GetVersion() >= base::win::VERSION_VISTA) |
1170 return; | 1171 return; |
1171 #endif | 1172 #endif |
1172 // Record a baseline. | 1173 // Record a baseline. |
1173 SpellCheckHostMetrics::RecordCustomWordCountStats(123); | 1174 SpellCheckHostMetrics::RecordCustomWordCountStats(123); |
1174 | 1175 |
1175 // Determine if test failures are due the statistics recorder not being | 1176 // Determine if test failures are due the statistics recorder not being |
1176 // available or because the histogram just isn't there: crbug.com/230534. | 1177 // available or because the histogram just isn't there: crbug.com/230534. |
1177 EXPECT_TRUE(StatisticsRecorder::IsActive()); | 1178 EXPECT_TRUE(StatisticsRecorder::IsActive()); |
1178 | 1179 |
1179 HistogramBase* histogram = | 1180 HistogramBase* histogram = |
1180 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); | 1181 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); |
1181 ASSERT_TRUE(histogram != NULL); | 1182 ASSERT_TRUE(histogram != NULL); |
1182 std::unique_ptr<HistogramSamples> baseline = histogram->SnapshotSamples(); | 1183 std::unique_ptr<HistogramSamples> baseline = histogram->SnapshotSamples(); |
1183 | 1184 |
1184 // Load the dictionary which should be empty. | 1185 // Load the dictionary which should be empty. |
1185 base::FilePath path = | 1186 base::FilePath path = |
1186 profile_.GetPath().Append(chrome::kCustomDictionaryFileName); | 1187 profile_.GetPath().Append(SpellcheckCustomDictionary::kCustomDictionaryFil
eName); |
1187 EXPECT_TRUE(LoadDictionaryFile(path)->words.empty()); | 1188 EXPECT_TRUE(LoadDictionaryFile(path)->words.empty()); |
1188 | 1189 |
1189 // We expect there to be an entry with 0. | 1190 // We expect there to be an entry with 0. |
1190 histogram = | 1191 histogram = |
1191 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); | 1192 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); |
1192 ASSERT_TRUE(histogram != NULL); | 1193 ASSERT_TRUE(histogram != NULL); |
1193 std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); | 1194 std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); |
1194 | 1195 |
1195 samples->Subtract(*baseline); | 1196 samples->Subtract(*baseline); |
1196 EXPECT_EQ(0,samples->sum()); | 1197 EXPECT_EQ(0,samples->sum()); |
(...skipping 21 matching lines...) Expand all Loading... |
1218 SpellcheckServiceFactory::GetForContext(&profile_); | 1219 SpellcheckServiceFactory::GetForContext(&profile_); |
1219 SpellcheckCustomDictionary* custom_dictionary = | 1220 SpellcheckCustomDictionary* custom_dictionary = |
1220 spellcheck_service->GetCustomDictionary(); | 1221 spellcheck_service->GetCustomDictionary(); |
1221 OnLoaded(*custom_dictionary, base::WrapUnique(new std::set<std::string>)); | 1222 OnLoaded(*custom_dictionary, base::WrapUnique(new std::set<std::string>)); |
1222 EXPECT_FALSE(custom_dictionary->HasWord("foo")); | 1223 EXPECT_FALSE(custom_dictionary->HasWord("foo")); |
1223 EXPECT_FALSE(custom_dictionary->HasWord("bar")); | 1224 EXPECT_FALSE(custom_dictionary->HasWord("bar")); |
1224 custom_dictionary->AddWord("foo"); | 1225 custom_dictionary->AddWord("foo"); |
1225 EXPECT_TRUE(custom_dictionary->HasWord("foo")); | 1226 EXPECT_TRUE(custom_dictionary->HasWord("foo")); |
1226 EXPECT_FALSE(custom_dictionary->HasWord("bar")); | 1227 EXPECT_FALSE(custom_dictionary->HasWord("bar")); |
1227 } | 1228 } |
OLD | NEW |