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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/metrics/histogram_samples.h" | 8 #include "base/metrics/histogram_samples.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" | 11 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" |
12 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 12 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
13 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 13 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
14 #include "chrome/browser/spellchecker/spellcheck_service.h" | 14 #include "chrome/browser/spellchecker/spellcheck_service.h" |
15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
16 #include "chrome/common/spellcheck_common.h" | 16 #include "chrome/common/spellcheck_common.h" |
17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
18 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
19 #include "net/url_request/test_url_fetcher_factory.h" | 19 #include "net/url_request/test_url_fetcher_factory.h" |
20 #include "sync/api/sync_change.h" | 20 #include "sync/api/sync_change.h" |
21 #include "sync/api/sync_change_processor_delegator.h" | |
21 #include "sync/api/sync_data.h" | 22 #include "sync/api/sync_data.h" |
22 #include "sync/api/sync_error_factory.h" | 23 #include "sync/api/sync_error_factory.h" |
23 #include "sync/api/sync_error_factory_mock.h" | 24 #include "sync/api/sync_error_factory_mock.h" |
24 #include "sync/protocol/sync.pb.h" | 25 #include "sync/protocol/sync.pb.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 | 28 |
28 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
29 // For version specific disabled tests below (http://crbug.com/230534). | 30 // For version specific disabled tests below (http://crbug.com/230534). |
30 #include "base/win/windows_version.h" | 31 #include "base/win/windows_version.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 const SpellcheckCustomDictionary::Change& change) { | 105 const SpellcheckCustomDictionary::Change& change) { |
105 return dictionary.Apply(change); | 106 return dictionary.Apply(change); |
106 } | 107 } |
107 | 108 |
108 content::TestBrowserThreadBundle thread_bundle_; | 109 content::TestBrowserThreadBundle thread_bundle_; |
109 | 110 |
110 TestingProfile profile_; | 111 TestingProfile profile_; |
111 net::TestURLFetcherFactory fetcher_factory_; | 112 net::TestURLFetcherFactory fetcher_factory_; |
112 }; | 113 }; |
113 | 114 |
114 // A wrapper around SpellcheckCustomDictionary that does not own the wrapped | |
115 // object. An instance of this class can be inside of a scoped pointer safely | |
116 // while the dictionary is managed by another scoped pointer. | |
117 class SyncChangeProcessorDelegate : public syncer::SyncChangeProcessor { | |
118 public: | |
119 explicit SyncChangeProcessorDelegate(SpellcheckCustomDictionary* dictionary) | |
120 : dictionary_(dictionary) {} | |
121 virtual ~SyncChangeProcessorDelegate() {} | |
122 | |
123 // Overridden from syncer::SyncChangeProcessor: | |
124 virtual syncer::SyncError ProcessSyncChanges( | |
125 const tracked_objects::Location& from_here, | |
126 const syncer::SyncChangeList& change_list) OVERRIDE { | |
127 return dictionary_->ProcessSyncChanges(from_here, change_list); | |
128 } | |
129 | |
130 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const | |
131 OVERRIDE { | |
132 return syncer::SyncDataList(); | |
133 } | |
134 | |
135 private: | |
136 SpellcheckCustomDictionary* dictionary_; | |
137 DISALLOW_COPY_AND_ASSIGN(SyncChangeProcessorDelegate); | |
138 }; | |
139 | |
140 // An implementation of SyncErrorFactory that does not upload the error message | 115 // An implementation of SyncErrorFactory that does not upload the error message |
141 // and updates an outside error counter. This lets us know the number of error | 116 // and updates an outside error counter. This lets us know the number of error |
142 // messages in an instance of this class after that instance is deleted. | 117 // messages in an instance of this class after that instance is deleted. |
143 class SyncErrorFactoryStub : public syncer::SyncErrorFactory { | 118 class SyncErrorFactoryStub : public syncer::SyncErrorFactory { |
144 public: | 119 public: |
145 explicit SyncErrorFactoryStub(int* error_counter) | 120 explicit SyncErrorFactoryStub(int* error_counter) |
146 : error_counter_(error_counter) {} | 121 : error_counter_(error_counter) {} |
147 virtual ~SyncErrorFactoryStub() {} | 122 virtual ~SyncErrorFactoryStub() {} |
148 | 123 |
149 // Overridden from syncer::SyncErrorFactory: | 124 // Overridden from syncer::SyncErrorFactory: |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 | 453 |
479 SpellcheckCustomDictionary::Change change2; | 454 SpellcheckCustomDictionary::Change change2; |
480 for (size_t i = 0; | 455 for (size_t i = 0; |
481 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; | 456 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; |
482 ++i) { | 457 ++i) { |
483 change2.AddWord("bar" + base::Uint64ToString(i)); | 458 change2.AddWord("bar" + base::Uint64ToString(i)); |
484 } | 459 } |
485 Apply(*custom_dictionary2, change2); | 460 Apply(*custom_dictionary2, change2); |
486 | 461 |
487 int error_counter = 0; | 462 int error_counter = 0; |
488 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 463 EXPECT_FALSE( |
489 syncer::DICTIONARY, | 464 custom_dictionary->MergeDataAndStartSyncing( |
groby-ooo-7-16
2014/02/06 19:52:04
nit: this indentation seems wrong. I'd expect
EXPE
maniscalco
2014/02/06 20:05:27
Surprised me too. This is what I ended up with af
groby-ooo-7-16
2014/02/06 22:03:17
Odd. Let's leave it for this CL - no need to fight
groby-ooo-7-16
2014/02/06 22:16:55
FWIW - this is semi-expected behavior from clang-f
| |
490 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 465 syncer::DICTIONARY, |
491 scoped_ptr<syncer::SyncChangeProcessor>( | 466 custom_dictionary2->GetAllSyncData( |
492 new SyncChangeProcessorDelegate(custom_dictionary2)), | 467 syncer::DICTIONARY), |
493 scoped_ptr<syncer::SyncErrorFactory>( | 468 scoped_ptr<syncer::SyncChangeProcessor>( |
494 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 469 new syncer::SyncChangeProcessorDelegator( |
470 custom_dictionary2)), | |
471 scoped_ptr<syncer::SyncErrorFactory>( | |
472 new SyncErrorFactoryStub(&error_counter))) | |
473 .error() | |
474 .IsSet()); | |
495 EXPECT_EQ(0, error_counter); | 475 EXPECT_EQ(0, error_counter); |
496 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 476 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
497 | 477 |
498 WordSet words = custom_dictionary->GetWords(); | 478 WordSet words = custom_dictionary->GetWords(); |
499 WordSet words2 = custom_dictionary2->GetWords(); | 479 WordSet words2 = custom_dictionary2->GetWords(); |
500 EXPECT_EQ(words.size(), words2.size()); | 480 EXPECT_EQ(words.size(), words2.size()); |
501 EXPECT_EQ(words, words2); | 481 EXPECT_EQ(words, words2); |
502 } | 482 } |
503 | 483 |
504 TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigBeforeSyncing) { | 484 TEST_F(SpellcheckCustomDictionaryTest, DictionaryTooBigBeforeSyncing) { |
(...skipping 11 matching lines...) Expand all Loading... | |
516 | 496 |
517 SpellcheckCustomDictionary::Change change; | 497 SpellcheckCustomDictionary::Change change; |
518 for (size_t i = 0; | 498 for (size_t i = 0; |
519 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1; | 499 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1; |
520 ++i) { | 500 ++i) { |
521 change.AddWord("foo" + base::Uint64ToString(i)); | 501 change.AddWord("foo" + base::Uint64ToString(i)); |
522 } | 502 } |
523 Apply(*custom_dictionary, change); | 503 Apply(*custom_dictionary, change); |
524 | 504 |
525 int error_counter = 0; | 505 int error_counter = 0; |
526 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 506 EXPECT_FALSE( |
527 syncer::DICTIONARY, | 507 custom_dictionary->MergeDataAndStartSyncing( |
528 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 508 syncer::DICTIONARY, |
529 scoped_ptr<syncer::SyncChangeProcessor>( | 509 custom_dictionary2->GetAllSyncData( |
530 new SyncChangeProcessorDelegate(custom_dictionary2)), | 510 syncer::DICTIONARY), |
531 scoped_ptr<syncer::SyncErrorFactory>( | 511 scoped_ptr<syncer::SyncChangeProcessor>( |
532 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 512 new syncer::SyncChangeProcessorDelegator( |
513 custom_dictionary2)), | |
514 scoped_ptr<syncer::SyncErrorFactory>( | |
515 new SyncErrorFactoryStub(&error_counter))) | |
516 .error() | |
517 .IsSet()); | |
533 EXPECT_EQ(0, error_counter); | 518 EXPECT_EQ(0, error_counter); |
534 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 519 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
535 | 520 |
536 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 521 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
537 custom_dictionary->GetWords().size()); | 522 custom_dictionary->GetWords().size()); |
538 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 523 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
539 custom_dictionary2->GetWords().size()); | 524 custom_dictionary2->GetWords().size()); |
540 | 525 |
541 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 526 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
542 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 527 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
(...skipping 25 matching lines...) Expand all Loading... | |
568 change.AddWord("foo"); | 553 change.AddWord("foo"); |
569 Apply(*custom_dictionary, change); | 554 Apply(*custom_dictionary, change); |
570 Apply(*custom_dictionary2, change2); | 555 Apply(*custom_dictionary2, change2); |
571 | 556 |
572 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 557 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
573 custom_dictionary->GetWords().size()); | 558 custom_dictionary->GetWords().size()); |
574 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 559 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
575 custom_dictionary2->GetWords().size()); | 560 custom_dictionary2->GetWords().size()); |
576 | 561 |
577 int error_counter = 0; | 562 int error_counter = 0; |
578 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 563 EXPECT_FALSE( |
579 syncer::DICTIONARY, | 564 custom_dictionary->MergeDataAndStartSyncing( |
580 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 565 syncer::DICTIONARY, |
581 scoped_ptr<syncer::SyncChangeProcessor>( | 566 custom_dictionary2->GetAllSyncData( |
582 new SyncChangeProcessorDelegate(custom_dictionary2)), | 567 syncer::DICTIONARY), |
583 scoped_ptr<syncer::SyncErrorFactory>( | 568 scoped_ptr<syncer::SyncChangeProcessor>( |
584 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 569 new syncer::SyncChangeProcessorDelegator( |
570 custom_dictionary2)), | |
571 scoped_ptr<syncer::SyncErrorFactory>( | |
572 new SyncErrorFactoryStub(&error_counter))) | |
573 .error() | |
574 .IsSet()); | |
585 EXPECT_EQ(0, error_counter); | 575 EXPECT_EQ(0, error_counter); |
586 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 576 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
587 | 577 |
588 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2 + 1, | 578 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2 + 1, |
589 custom_dictionary->GetWords().size()); | 579 custom_dictionary->GetWords().size()); |
590 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 580 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
591 custom_dictionary2->GetWords().size()); | 581 custom_dictionary2->GetWords().size()); |
592 | 582 |
593 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 583 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
594 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 584 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
(...skipping 24 matching lines...) Expand all Loading... | |
619 } | 609 } |
620 Apply(*custom_dictionary, change); | 610 Apply(*custom_dictionary, change); |
621 Apply(*custom_dictionary2, change2); | 611 Apply(*custom_dictionary2, change2); |
622 | 612 |
623 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 613 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
624 custom_dictionary->GetWords().size()); | 614 custom_dictionary->GetWords().size()); |
625 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 615 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
626 custom_dictionary2->GetWords().size()); | 616 custom_dictionary2->GetWords().size()); |
627 | 617 |
628 int error_counter = 0; | 618 int error_counter = 0; |
629 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 619 EXPECT_FALSE( |
630 syncer::DICTIONARY, | 620 custom_dictionary->MergeDataAndStartSyncing( |
631 GetAllSyncDataNoLimit(custom_dictionary2), | 621 syncer::DICTIONARY, |
632 scoped_ptr<syncer::SyncChangeProcessor>( | 622 GetAllSyncDataNoLimit(custom_dictionary2), |
633 new SyncChangeProcessorDelegate(custom_dictionary2)), | 623 scoped_ptr<syncer::SyncChangeProcessor>( |
634 scoped_ptr<syncer::SyncErrorFactory>( | 624 new syncer::SyncChangeProcessorDelegator( |
635 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 625 custom_dictionary2)), |
626 scoped_ptr<syncer::SyncErrorFactory>( | |
627 new SyncErrorFactoryStub(&error_counter))) | |
628 .error() | |
629 .IsSet()); | |
636 EXPECT_EQ(0, error_counter); | 630 EXPECT_EQ(0, error_counter); |
637 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 631 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
638 | 632 |
639 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2 + 2, | 633 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2 + 2, |
640 custom_dictionary->GetWords().size()); | 634 custom_dictionary->GetWords().size()); |
641 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 635 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
642 custom_dictionary2->GetWords().size()); | 636 custom_dictionary2->GetWords().size()); |
643 | 637 |
644 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 638 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
645 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 639 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
(...skipping 19 matching lines...) Expand all Loading... | |
665 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; | 659 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; |
666 ++i) { | 660 ++i) { |
667 change.AddWord("foo" + base::Uint64ToString(i)); | 661 change.AddWord("foo" + base::Uint64ToString(i)); |
668 } | 662 } |
669 Apply(*custom_dictionary, change); | 663 Apply(*custom_dictionary, change); |
670 | 664 |
671 custom_dictionary2->AddWord("bar"); | 665 custom_dictionary2->AddWord("bar"); |
672 custom_dictionary2->AddWord("baz"); | 666 custom_dictionary2->AddWord("baz"); |
673 | 667 |
674 int error_counter = 0; | 668 int error_counter = 0; |
675 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 669 EXPECT_FALSE( |
676 syncer::DICTIONARY, | 670 custom_dictionary->MergeDataAndStartSyncing( |
677 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 671 syncer::DICTIONARY, |
678 scoped_ptr<syncer::SyncChangeProcessor>( | 672 custom_dictionary2->GetAllSyncData( |
679 new SyncChangeProcessorDelegate(custom_dictionary2)), | 673 syncer::DICTIONARY), |
680 scoped_ptr<syncer::SyncErrorFactory>( | 674 scoped_ptr<syncer::SyncChangeProcessor>( |
681 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 675 new syncer::SyncChangeProcessorDelegator( |
676 custom_dictionary2)), | |
677 scoped_ptr<syncer::SyncErrorFactory>( | |
678 new SyncErrorFactoryStub(&error_counter))) | |
679 .error() | |
680 .IsSet()); | |
682 EXPECT_EQ(0, error_counter); | 681 EXPECT_EQ(0, error_counter); |
683 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 682 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
684 | 683 |
685 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, | 684 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS + 1, |
686 custom_dictionary->GetWords().size()); | 685 custom_dictionary->GetWords().size()); |
687 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 686 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
688 custom_dictionary2->GetWords().size()); | 687 custom_dictionary2->GetWords().size()); |
689 | 688 |
690 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 689 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
691 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); | 690 custom_dictionary->GetAllSyncData(syncer::DICTIONARY).size()); |
(...skipping 16 matching lines...) Expand all Loading... | |
708 | 707 |
709 SpellcheckCustomDictionary::Change change; | 708 SpellcheckCustomDictionary::Change change; |
710 for (size_t i = 0; | 709 for (size_t i = 0; |
711 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; | 710 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS - 1; |
712 ++i) { | 711 ++i) { |
713 change.AddWord("foo" + base::Uint64ToString(i)); | 712 change.AddWord("foo" + base::Uint64ToString(i)); |
714 } | 713 } |
715 Apply(*custom_dictionary, change); | 714 Apply(*custom_dictionary, change); |
716 | 715 |
717 int error_counter = 0; | 716 int error_counter = 0; |
718 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 717 EXPECT_FALSE( |
719 syncer::DICTIONARY, | 718 custom_dictionary->MergeDataAndStartSyncing( |
720 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 719 syncer::DICTIONARY, |
721 scoped_ptr<syncer::SyncChangeProcessor>( | 720 custom_dictionary2->GetAllSyncData( |
722 new SyncChangeProcessorDelegate(custom_dictionary2)), | 721 syncer::DICTIONARY), |
723 scoped_ptr<syncer::SyncErrorFactory>( | 722 scoped_ptr<syncer::SyncChangeProcessor>( |
724 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 723 new syncer::SyncChangeProcessorDelegator( |
724 custom_dictionary2)), | |
725 scoped_ptr<syncer::SyncErrorFactory>( | |
726 new SyncErrorFactoryStub(&error_counter))) | |
727 .error() | |
728 .IsSet()); | |
725 EXPECT_EQ(0, error_counter); | 729 EXPECT_EQ(0, error_counter); |
726 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 730 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
727 | 731 |
728 custom_dictionary->AddWord("bar"); | 732 custom_dictionary->AddWord("bar"); |
729 EXPECT_EQ(0, error_counter); | 733 EXPECT_EQ(0, error_counter); |
730 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 734 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
731 | 735 |
732 custom_dictionary->AddWord("baz"); | 736 custom_dictionary->AddWord("baz"); |
733 EXPECT_EQ(0, error_counter); | 737 EXPECT_EQ(0, error_counter); |
734 EXPECT_FALSE(custom_dictionary->IsSyncing()); | 738 EXPECT_FALSE(custom_dictionary->IsSyncing()); |
(...skipping 18 matching lines...) Expand all Loading... | |
753 SpellcheckService* spellcheck_service2 = | 757 SpellcheckService* spellcheck_service2 = |
754 static_cast<SpellcheckService*>( | 758 static_cast<SpellcheckService*>( |
755 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 759 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
756 &profile2, &BuildSpellcheckService)); | 760 &profile2, &BuildSpellcheckService)); |
757 SpellcheckCustomDictionary* custom_dictionary2 = | 761 SpellcheckCustomDictionary* custom_dictionary2 = |
758 spellcheck_service2->GetCustomDictionary(); | 762 spellcheck_service2->GetCustomDictionary(); |
759 | 763 |
760 custom_dictionary->AddWord("foo"); | 764 custom_dictionary->AddWord("foo"); |
761 | 765 |
762 int error_counter = 0; | 766 int error_counter = 0; |
763 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 767 EXPECT_FALSE( |
764 syncer::DICTIONARY, | 768 custom_dictionary->MergeDataAndStartSyncing( |
765 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 769 syncer::DICTIONARY, |
766 scoped_ptr<syncer::SyncChangeProcessor>( | 770 custom_dictionary2->GetAllSyncData( |
767 new SyncChangeProcessorDelegate(custom_dictionary2)), | 771 syncer::DICTIONARY), |
768 scoped_ptr<syncer::SyncErrorFactory>( | 772 scoped_ptr<syncer::SyncChangeProcessor>( |
769 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 773 new syncer::SyncChangeProcessorDelegator( |
774 custom_dictionary2)), | |
775 scoped_ptr<syncer::SyncErrorFactory>( | |
776 new SyncErrorFactoryStub(&error_counter))) | |
777 .error() | |
778 .IsSet()); | |
770 EXPECT_EQ(0, error_counter); | 779 EXPECT_EQ(0, error_counter); |
771 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 780 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
772 | 781 |
773 WordList custom_words; | 782 WordList custom_words; |
774 custom_words.push_back("bar"); | 783 custom_words.push_back("bar"); |
775 OnLoaded(*custom_dictionary, custom_words); | 784 OnLoaded(*custom_dictionary, custom_words); |
776 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 785 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
777 | 786 |
778 EXPECT_EQ(2UL, custom_dictionary->GetWords().size()); | 787 EXPECT_EQ(2UL, custom_dictionary->GetWords().size()); |
779 EXPECT_EQ(2UL, custom_dictionary2->GetWords().size()); | 788 EXPECT_EQ(2UL, custom_dictionary2->GetWords().size()); |
(...skipping 11 matching lines...) Expand all Loading... | |
791 SpellcheckService* spellcheck_service2 = | 800 SpellcheckService* spellcheck_service2 = |
792 static_cast<SpellcheckService*>( | 801 static_cast<SpellcheckService*>( |
793 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 802 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
794 &profile2, &BuildSpellcheckService)); | 803 &profile2, &BuildSpellcheckService)); |
795 SpellcheckCustomDictionary* custom_dictionary2 = | 804 SpellcheckCustomDictionary* custom_dictionary2 = |
796 spellcheck_service2->GetCustomDictionary(); | 805 spellcheck_service2->GetCustomDictionary(); |
797 | 806 |
798 custom_dictionary->AddWord("foo"); | 807 custom_dictionary->AddWord("foo"); |
799 | 808 |
800 int error_counter = 0; | 809 int error_counter = 0; |
801 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 810 EXPECT_FALSE( |
802 syncer::DICTIONARY, | 811 custom_dictionary->MergeDataAndStartSyncing( |
803 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 812 syncer::DICTIONARY, |
804 scoped_ptr<syncer::SyncChangeProcessor>( | 813 custom_dictionary2->GetAllSyncData( |
805 new SyncChangeProcessorDelegate(custom_dictionary2)), | 814 syncer::DICTIONARY), |
806 scoped_ptr<syncer::SyncErrorFactory>( | 815 scoped_ptr<syncer::SyncChangeProcessor>( |
807 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 816 new syncer::SyncChangeProcessorDelegator( |
817 custom_dictionary2)), | |
818 scoped_ptr<syncer::SyncErrorFactory>( | |
819 new SyncErrorFactoryStub(&error_counter))) | |
820 .error() | |
821 .IsSet()); | |
808 EXPECT_EQ(0, error_counter); | 822 EXPECT_EQ(0, error_counter); |
809 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 823 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
810 | 824 |
811 WordList custom_words; | 825 WordList custom_words; |
812 for (size_t i = 0; | 826 for (size_t i = 0; |
813 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; | 827 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; |
814 ++i) { | 828 ++i) { |
815 custom_words.push_back("foo" + base::Uint64ToString(i)); | 829 custom_words.push_back("foo" + base::Uint64ToString(i)); |
816 } | 830 } |
817 OnLoaded(*custom_dictionary, custom_words); | 831 OnLoaded(*custom_dictionary, custom_words); |
(...skipping 26 matching lines...) Expand all Loading... | |
844 | 858 |
845 WordList to_add; | 859 WordList to_add; |
846 for (size_t i = 0; | 860 for (size_t i = 0; |
847 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; | 861 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2; |
848 ++i) { | 862 ++i) { |
849 to_add.push_back("foo" + base::Uint64ToString(i)); | 863 to_add.push_back("foo" + base::Uint64ToString(i)); |
850 } | 864 } |
851 Apply(*custom_dictionary, SpellcheckCustomDictionary::Change(to_add)); | 865 Apply(*custom_dictionary, SpellcheckCustomDictionary::Change(to_add)); |
852 | 866 |
853 int error_counter = 0; | 867 int error_counter = 0; |
854 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 868 EXPECT_FALSE( |
855 syncer::DICTIONARY, | 869 custom_dictionary->MergeDataAndStartSyncing( |
856 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 870 syncer::DICTIONARY, |
857 scoped_ptr<syncer::SyncChangeProcessor>( | 871 custom_dictionary2->GetAllSyncData( |
858 new SyncChangeProcessorDelegate(custom_dictionary2)), | 872 syncer::DICTIONARY), |
859 scoped_ptr<syncer::SyncErrorFactory>( | 873 scoped_ptr<syncer::SyncChangeProcessor>( |
860 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 874 new syncer::SyncChangeProcessorDelegator( |
875 custom_dictionary2)), | |
876 scoped_ptr<syncer::SyncErrorFactory>( | |
877 new SyncErrorFactoryStub(&error_counter))) | |
878 .error() | |
879 .IsSet()); | |
861 EXPECT_EQ(0, error_counter); | 880 EXPECT_EQ(0, error_counter); |
862 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 881 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
863 | 882 |
864 OnLoaded(*custom_dictionary, to_add); | 883 OnLoaded(*custom_dictionary, to_add); |
865 EXPECT_EQ(0, error_counter); | 884 EXPECT_EQ(0, error_counter); |
866 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 885 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
867 | 886 |
868 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, | 887 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, |
869 custom_dictionary->GetWords().size()); | 888 custom_dictionary->GetWords().size()); |
870 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, | 889 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS / 2, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 custom_dictionary2->AddWord("foo"); | 980 custom_dictionary2->AddWord("foo"); |
962 custom_dictionary2->AddWord("baz"); | 981 custom_dictionary2->AddWord("baz"); |
963 | 982 |
964 DictionaryObserverCounter observer; | 983 DictionaryObserverCounter observer; |
965 custom_dictionary->AddObserver(&observer); | 984 custom_dictionary->AddObserver(&observer); |
966 | 985 |
967 DictionaryObserverCounter observer2; | 986 DictionaryObserverCounter observer2; |
968 custom_dictionary2->AddObserver(&observer2); | 987 custom_dictionary2->AddObserver(&observer2); |
969 | 988 |
970 int error_counter = 0; | 989 int error_counter = 0; |
971 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 990 EXPECT_FALSE( |
972 syncer::DICTIONARY, | 991 custom_dictionary->MergeDataAndStartSyncing( |
973 custom_dictionary2->GetAllSyncData(syncer::DICTIONARY), | 992 syncer::DICTIONARY, |
974 scoped_ptr<syncer::SyncChangeProcessor>( | 993 custom_dictionary2->GetAllSyncData( |
975 new SyncChangeProcessorDelegate(custom_dictionary2)), | 994 syncer::DICTIONARY), |
976 scoped_ptr<syncer::SyncErrorFactory>( | 995 scoped_ptr<syncer::SyncChangeProcessor>( |
977 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 996 new syncer::SyncChangeProcessorDelegator( |
997 custom_dictionary2)), | |
998 scoped_ptr<syncer::SyncErrorFactory>( | |
999 new SyncErrorFactoryStub(&error_counter))) | |
1000 .error() | |
1001 .IsSet()); | |
978 EXPECT_EQ(0, error_counter); | 1002 EXPECT_EQ(0, error_counter); |
979 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 1003 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
980 | 1004 |
981 EXPECT_EQ(1, observer.changes()); | 1005 EXPECT_EQ(1, observer.changes()); |
982 EXPECT_EQ(1, observer2.changes()); | 1006 EXPECT_EQ(1, observer2.changes()); |
983 | 1007 |
984 custom_dictionary->RemoveObserver(&observer); | 1008 custom_dictionary->RemoveObserver(&observer); |
985 custom_dictionary2->RemoveObserver(&observer2); | 1009 custom_dictionary2->RemoveObserver(&observer2); |
986 } | 1010 } |
987 | 1011 |
(...skipping 21 matching lines...) Expand all Loading... | |
1009 | 1033 |
1010 SpellcheckCustomDictionary::Change change; | 1034 SpellcheckCustomDictionary::Change change; |
1011 for (size_t i = 0; | 1035 for (size_t i = 0; |
1012 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; | 1036 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; |
1013 ++i) { | 1037 ++i) { |
1014 change.AddWord("foo" + base::Uint64ToString(i)); | 1038 change.AddWord("foo" + base::Uint64ToString(i)); |
1015 } | 1039 } |
1016 Apply(*custom_dictionary, change); | 1040 Apply(*custom_dictionary, change); |
1017 | 1041 |
1018 int error_counter = 0; | 1042 int error_counter = 0; |
1019 EXPECT_FALSE(custom_dictionary->MergeDataAndStartSyncing( | 1043 EXPECT_FALSE( |
1020 syncer::DICTIONARY, | 1044 custom_dictionary->MergeDataAndStartSyncing( |
1021 server_custom_dictionary->GetAllSyncData(syncer::DICTIONARY), | 1045 syncer::DICTIONARY, |
1022 scoped_ptr<syncer::SyncChangeProcessor>( | 1046 server_custom_dictionary->GetAllSyncData( |
1023 new SyncChangeProcessorDelegate(server_custom_dictionary)), | 1047 syncer::DICTIONARY), |
1024 scoped_ptr<syncer::SyncErrorFactory>( | 1048 scoped_ptr<syncer::SyncChangeProcessor>( |
1025 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 1049 new syncer::SyncChangeProcessorDelegator( |
1050 server_custom_dictionary)), | |
1051 scoped_ptr<syncer::SyncErrorFactory>( | |
1052 new SyncErrorFactoryStub(&error_counter))) | |
1053 .error() | |
1054 .IsSet()); | |
1026 EXPECT_EQ(0, error_counter); | 1055 EXPECT_EQ(0, error_counter); |
1027 EXPECT_TRUE(custom_dictionary->IsSyncing()); | 1056 EXPECT_TRUE(custom_dictionary->IsSyncing()); |
1028 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 1057 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
1029 custom_dictionary->GetWords().size()); | 1058 custom_dictionary->GetWords().size()); |
1030 } | 1059 } |
1031 | 1060 |
1032 // The sync server now has the maximum number of words. | 1061 // The sync server now has the maximum number of words. |
1033 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 1062 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
1034 server_custom_dictionary->GetWords().size()); | 1063 server_custom_dictionary->GetWords().size()); |
1035 | 1064 |
(...skipping 16 matching lines...) Expand all Loading... | |
1052 SpellcheckCustomDictionary::Change change; | 1081 SpellcheckCustomDictionary::Change change; |
1053 for (size_t i = 0; | 1082 for (size_t i = 0; |
1054 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; | 1083 i < chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS; |
1055 ++i) { | 1084 ++i) { |
1056 change.AddWord("bar" + base::Uint64ToString(i)); | 1085 change.AddWord("bar" + base::Uint64ToString(i)); |
1057 } | 1086 } |
1058 Apply(*client_custom_dictionary, change); | 1087 Apply(*client_custom_dictionary, change); |
1059 | 1088 |
1060 // Associate the server and the client. | 1089 // Associate the server and the client. |
1061 int error_counter = 0; | 1090 int error_counter = 0; |
1062 EXPECT_FALSE(client_custom_dictionary->MergeDataAndStartSyncing( | 1091 EXPECT_FALSE( |
1063 syncer::DICTIONARY, | 1092 client_custom_dictionary |
1064 server_custom_dictionary->GetAllSyncData(syncer::DICTIONARY), | 1093 ->MergeDataAndStartSyncing( |
1065 scoped_ptr<syncer::SyncChangeProcessor>( | 1094 syncer::DICTIONARY, |
1066 new SyncChangeProcessorDelegate(server_custom_dictionary)), | 1095 server_custom_dictionary->GetAllSyncData(syncer::DICTIONARY), |
1067 scoped_ptr<syncer::SyncErrorFactory>( | 1096 scoped_ptr<syncer::SyncChangeProcessor>( |
1068 new SyncErrorFactoryStub(&error_counter))).error().IsSet()); | 1097 new syncer::SyncChangeProcessorDelegator( |
1098 server_custom_dictionary)), | |
1099 scoped_ptr<syncer::SyncErrorFactory>( | |
1100 new SyncErrorFactoryStub(&error_counter))) | |
1101 .error() | |
1102 .IsSet()); | |
1069 EXPECT_EQ(0, error_counter); | 1103 EXPECT_EQ(0, error_counter); |
1070 EXPECT_FALSE(client_custom_dictionary->IsSyncing()); | 1104 EXPECT_FALSE(client_custom_dictionary->IsSyncing()); |
1071 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2, | 1105 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS * 2, |
1072 client_custom_dictionary->GetWords().size()); | 1106 client_custom_dictionary->GetWords().size()); |
1073 } | 1107 } |
1074 | 1108 |
1075 // The sync server should not receive more words, because it has the maximum | 1109 // The sync server should not receive more words, because it has the maximum |
1076 // number of words already. | 1110 // number of words already. |
1077 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, | 1111 EXPECT_EQ(chrome::spellcheck_common::MAX_SYNCABLE_DICTIONARY_WORDS, |
1078 server_custom_dictionary->GetWords().size()); | 1112 server_custom_dictionary->GetWords().size()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1134 SpellcheckServiceFactory::GetForContext(&profile_); | 1168 SpellcheckServiceFactory::GetForContext(&profile_); |
1135 SpellcheckCustomDictionary* custom_dictionary = | 1169 SpellcheckCustomDictionary* custom_dictionary = |
1136 spellcheck_service->GetCustomDictionary(); | 1170 spellcheck_service->GetCustomDictionary(); |
1137 OnLoaded(*custom_dictionary, WordList()); | 1171 OnLoaded(*custom_dictionary, WordList()); |
1138 EXPECT_FALSE(custom_dictionary->HasWord("foo")); | 1172 EXPECT_FALSE(custom_dictionary->HasWord("foo")); |
1139 EXPECT_FALSE(custom_dictionary->HasWord("bar")); | 1173 EXPECT_FALSE(custom_dictionary->HasWord("bar")); |
1140 custom_dictionary->AddWord("foo"); | 1174 custom_dictionary->AddWord("foo"); |
1141 EXPECT_TRUE(custom_dictionary->HasWord("foo")); | 1175 EXPECT_TRUE(custom_dictionary->HasWord("foo")); |
1142 EXPECT_FALSE(custom_dictionary->HasWord("bar")); | 1176 EXPECT_FALSE(custom_dictionary->HasWord("bar")); |
1143 } | 1177 } |
OLD | NEW |