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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 629733002: replace OVERRIDE and FINAL with override and final in sync/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_rollback_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 // Finally, the attachment is no longer linked. 686 // Finally, the attachment is no longer linked.
687 ASSERT_FALSE(dir()->IsAttachmentLinked(attachment_id.GetProto())); 687 ASSERT_FALSE(dir()->IsAttachmentLinked(attachment_id.GetProto()));
688 } 688 }
689 689
690 namespace { 690 namespace {
691 691
692 class TestHttpPostProviderInterface : public HttpPostProviderInterface { 692 class TestHttpPostProviderInterface : public HttpPostProviderInterface {
693 public: 693 public:
694 virtual ~TestHttpPostProviderInterface() {} 694 virtual ~TestHttpPostProviderInterface() {}
695 695
696 virtual void SetExtraRequestHeaders(const char* headers) OVERRIDE {} 696 virtual void SetExtraRequestHeaders(const char* headers) override {}
697 virtual void SetURL(const char* url, int port) OVERRIDE {} 697 virtual void SetURL(const char* url, int port) override {}
698 virtual void SetPostPayload(const char* content_type, 698 virtual void SetPostPayload(const char* content_type,
699 int content_length, 699 int content_length,
700 const char* content) OVERRIDE {} 700 const char* content) override {}
701 virtual bool MakeSynchronousPost(int* error_code, int* response_code) 701 virtual bool MakeSynchronousPost(int* error_code, int* response_code)
702 OVERRIDE { 702 override {
703 return false; 703 return false;
704 } 704 }
705 virtual int GetResponseContentLength() const OVERRIDE { 705 virtual int GetResponseContentLength() const override {
706 return 0; 706 return 0;
707 } 707 }
708 virtual const char* GetResponseContent() const OVERRIDE { 708 virtual const char* GetResponseContent() const override {
709 return ""; 709 return "";
710 } 710 }
711 virtual const std::string GetResponseHeaderValue( 711 virtual const std::string GetResponseHeaderValue(
712 const std::string& name) const OVERRIDE { 712 const std::string& name) const override {
713 return std::string(); 713 return std::string();
714 } 714 }
715 virtual void Abort() OVERRIDE {} 715 virtual void Abort() override {}
716 }; 716 };
717 717
718 class TestHttpPostProviderFactory : public HttpPostProviderFactory { 718 class TestHttpPostProviderFactory : public HttpPostProviderFactory {
719 public: 719 public:
720 virtual ~TestHttpPostProviderFactory() {} 720 virtual ~TestHttpPostProviderFactory() {}
721 virtual void Init(const std::string& user_agent) OVERRIDE { } 721 virtual void Init(const std::string& user_agent) override { }
722 virtual HttpPostProviderInterface* Create() OVERRIDE { 722 virtual HttpPostProviderInterface* Create() override {
723 return new TestHttpPostProviderInterface(); 723 return new TestHttpPostProviderInterface();
724 } 724 }
725 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE { 725 virtual void Destroy(HttpPostProviderInterface* http) override {
726 delete static_cast<TestHttpPostProviderInterface*>(http); 726 delete static_cast<TestHttpPostProviderInterface*>(http);
727 } 727 }
728 }; 728 };
729 729
730 class SyncManagerObserverMock : public SyncManager::Observer { 730 class SyncManagerObserverMock : public SyncManager::Observer {
731 public: 731 public:
732 MOCK_METHOD1(OnSyncCycleCompleted, 732 MOCK_METHOD1(OnSyncCycleCompleted,
733 void(const SyncSessionSnapshot&)); // NOLINT 733 void(const SyncSessionSnapshot&)); // NOLINT
734 MOCK_METHOD4(OnInitializationComplete, 734 MOCK_METHOD4(OnInitializationComplete,
735 void(const WeakHandle<JsBackend>&, 735 void(const WeakHandle<JsBackend>&,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 ModelTypeSet GetEnabledTypes() { 870 ModelTypeSet GetEnabledTypes() {
871 ModelSafeRoutingInfo routing_info; 871 ModelSafeRoutingInfo routing_info;
872 GetModelSafeRoutingInfo(&routing_info); 872 GetModelSafeRoutingInfo(&routing_info);
873 return GetRoutingInfoTypes(routing_info); 873 return GetRoutingInfoTypes(routing_info);
874 } 874 }
875 875
876 virtual void OnChangesApplied( 876 virtual void OnChangesApplied(
877 ModelType model_type, 877 ModelType model_type,
878 int64 model_version, 878 int64 model_version,
879 const BaseTransaction* trans, 879 const BaseTransaction* trans,
880 const ImmutableChangeRecordList& changes) OVERRIDE {} 880 const ImmutableChangeRecordList& changes) override {}
881 881
882 virtual void OnChangesComplete(ModelType model_type) OVERRIDE {} 882 virtual void OnChangesComplete(ModelType model_type) override {}
883 883
884 // Helper methods. 884 // Helper methods.
885 bool SetUpEncryption(NigoriStatus nigori_status, 885 bool SetUpEncryption(NigoriStatus nigori_status,
886 EncryptionStatus encryption_status) { 886 EncryptionStatus encryption_status) {
887 UserShare* share = sync_manager_.GetUserShare(); 887 UserShare* share = sync_manager_.GetUserShare();
888 888
889 // We need to create the nigori node as if it were an applied server update. 889 // We need to create the nigori node as if it were an applied server update.
890 int64 nigori_id = GetIdForDataType(NIGORI); 890 int64 nigori_id = GetIdForDataType(NIGORI);
891 if (nigori_id == kInvalidId) 891 if (nigori_id == kInvalidId)
892 return false; 892 return false;
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 InternalComponentsFactory::StorageOption* storage_used) 2404 InternalComponentsFactory::StorageOption* storage_used)
2405 : TestInternalComponentsFactory( 2405 : TestInternalComponentsFactory(
2406 switches, InternalComponentsFactory::STORAGE_IN_MEMORY, storage_used), 2406 switches, InternalComponentsFactory::STORAGE_IN_MEMORY, storage_used),
2407 scheduler_to_use_(scheduler_to_use), 2407 scheduler_to_use_(scheduler_to_use),
2408 session_context_(session_context) {} 2408 session_context_(session_context) {}
2409 virtual ~ComponentsFactory() {} 2409 virtual ~ComponentsFactory() {}
2410 2410
2411 virtual scoped_ptr<SyncScheduler> BuildScheduler( 2411 virtual scoped_ptr<SyncScheduler> BuildScheduler(
2412 const std::string& name, 2412 const std::string& name,
2413 sessions::SyncSessionContext* context, 2413 sessions::SyncSessionContext* context,
2414 CancelationSignal* stop_handle) OVERRIDE { 2414 CancelationSignal* stop_handle) override {
2415 *session_context_ = context; 2415 *session_context_ = context;
2416 return scheduler_to_use_.Pass(); 2416 return scheduler_to_use_.Pass();
2417 } 2417 }
2418 2418
2419 private: 2419 private:
2420 scoped_ptr<SyncScheduler> scheduler_to_use_; 2420 scoped_ptr<SyncScheduler> scheduler_to_use_;
2421 sessions::SyncSessionContext** session_context_; 2421 sessions::SyncSessionContext** session_context_;
2422 }; 2422 };
2423 2423
2424 class SyncManagerTestWithMockScheduler : public SyncManagerTest { 2424 class SyncManagerTestWithMockScheduler : public SyncManagerTest {
2425 public: 2425 public:
2426 SyncManagerTestWithMockScheduler() : scheduler_(NULL) {} 2426 SyncManagerTestWithMockScheduler() : scheduler_(NULL) {}
2427 virtual InternalComponentsFactory* GetFactory() OVERRIDE { 2427 virtual InternalComponentsFactory* GetFactory() override {
2428 scheduler_ = new MockSyncScheduler(); 2428 scheduler_ = new MockSyncScheduler();
2429 return new ComponentsFactory(GetSwitches(), scheduler_, &session_context_, 2429 return new ComponentsFactory(GetSwitches(), scheduler_, &session_context_,
2430 &storage_used_); 2430 &storage_used_);
2431 } 2431 }
2432 2432
2433 MockSyncScheduler* scheduler() { return scheduler_; } 2433 MockSyncScheduler* scheduler() { return scheduler_; }
2434 sessions::SyncSessionContext* session_context() { 2434 sessions::SyncSessionContext* session_context() {
2435 return session_context_; 2435 return session_context_;
2436 } 2436 }
2437 2437
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 2808
2809 // A test harness to exercise the code that processes and passes changes from 2809 // A test harness to exercise the code that processes and passes changes from
2810 // the "SYNCER"-WriteTransaction destructor, through the SyncManager, to the 2810 // the "SYNCER"-WriteTransaction destructor, through the SyncManager, to the
2811 // ChangeProcessor. 2811 // ChangeProcessor.
2812 class SyncManagerChangeProcessingTest : public SyncManagerTest { 2812 class SyncManagerChangeProcessingTest : public SyncManagerTest {
2813 public: 2813 public:
2814 virtual void OnChangesApplied( 2814 virtual void OnChangesApplied(
2815 ModelType model_type, 2815 ModelType model_type,
2816 int64 model_version, 2816 int64 model_version,
2817 const BaseTransaction* trans, 2817 const BaseTransaction* trans,
2818 const ImmutableChangeRecordList& changes) OVERRIDE { 2818 const ImmutableChangeRecordList& changes) override {
2819 last_changes_ = changes; 2819 last_changes_ = changes;
2820 } 2820 }
2821 2821
2822 virtual void OnChangesComplete(ModelType model_type) OVERRIDE {} 2822 virtual void OnChangesComplete(ModelType model_type) override {}
2823 2823
2824 const ImmutableChangeRecordList& GetRecentChangeList() { 2824 const ImmutableChangeRecordList& GetRecentChangeList() {
2825 return last_changes_; 2825 return last_changes_;
2826 } 2826 }
2827 2827
2828 UserShare* share() { 2828 UserShare* share() {
2829 return sync_manager_.GetUserShare(); 2829 return sync_manager_.GetUserShare();
2830 } 2830 }
2831 2831
2832 // Set some flags so our nodes reasonably approximate the real world scenario 2832 // Set some flags so our nodes reasonably approximate the real world scenario
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 // During initialization SyncManagerImpl loads sqlite database. If it fails to 3163 // During initialization SyncManagerImpl loads sqlite database. If it fails to
3164 // do so it should fail initialization. This test verifies this behavior. 3164 // do so it should fail initialization. This test verifies this behavior.
3165 // Test reuses SyncManagerImpl initialization from SyncManagerTest but overrides 3165 // Test reuses SyncManagerImpl initialization from SyncManagerTest but overrides
3166 // InternalComponentsFactory to return DirectoryBackingStore that always fails 3166 // InternalComponentsFactory to return DirectoryBackingStore that always fails
3167 // to load. 3167 // to load.
3168 class SyncManagerInitInvalidStorageTest : public SyncManagerTest { 3168 class SyncManagerInitInvalidStorageTest : public SyncManagerTest {
3169 public: 3169 public:
3170 SyncManagerInitInvalidStorageTest() { 3170 SyncManagerInitInvalidStorageTest() {
3171 } 3171 }
3172 3172
3173 virtual InternalComponentsFactory* GetFactory() OVERRIDE { 3173 virtual InternalComponentsFactory* GetFactory() override {
3174 return new TestInternalComponentsFactory( 3174 return new TestInternalComponentsFactory(
3175 GetSwitches(), InternalComponentsFactory::STORAGE_INVALID, 3175 GetSwitches(), InternalComponentsFactory::STORAGE_INVALID,
3176 &storage_used_); 3176 &storage_used_);
3177 } 3177 }
3178 }; 3178 };
3179 3179
3180 // SyncManagerInitInvalidStorageTest::GetFactory will return 3180 // SyncManagerInitInvalidStorageTest::GetFactory will return
3181 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3181 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3182 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3182 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3183 // task is to ensure that SyncManagerImpl reported initialization failure in 3183 // task is to ensure that SyncManagerImpl reported initialization failure in
3184 // OnInitializationComplete callback. 3184 // OnInitializationComplete callback.
3185 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3185 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3186 EXPECT_FALSE(initialization_succeeded_); 3186 EXPECT_FALSE(initialization_succeeded_);
3187 } 3187 }
3188 3188
3189 } // namespace syncer 3189 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_rollback_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698