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

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

Issue 23658030: Revert 222154 "sync: Gracefully handle very early shutdown" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/files/scoped_temp_dir.h" 15 #include "base/files/scoped_temp_dir.h"
16 #include "base/format_macros.h" 16 #include "base/format_macros.h"
17 #include "base/location.h" 17 #include "base/location.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/message_loop/message_loop_proxy.h" 20 #include "base/message_loop/message_loop_proxy.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
24 #include "base/test/values_test_util.h" 24 #include "base/test/values_test_util.h"
25 #include "base/values.h" 25 #include "base/values.h"
26 #include "sync/engine/sync_scheduler.h" 26 #include "sync/engine/sync_scheduler.h"
27 #include "sync/internal_api/public/base/cancelation_signal.h"
28 #include "sync/internal_api/public/base/model_type_test_util.h" 27 #include "sync/internal_api/public/base/model_type_test_util.h"
29 #include "sync/internal_api/public/change_record.h" 28 #include "sync/internal_api/public/change_record.h"
30 #include "sync/internal_api/public/engine/model_safe_worker.h" 29 #include "sync/internal_api/public/engine/model_safe_worker.h"
31 #include "sync/internal_api/public/engine/polling_constants.h" 30 #include "sync/internal_api/public/engine/polling_constants.h"
32 #include "sync/internal_api/public/http_post_provider_factory.h" 31 #include "sync/internal_api/public/http_post_provider_factory.h"
33 #include "sync/internal_api/public/http_post_provider_interface.h" 32 #include "sync/internal_api/public/http_post_provider_interface.h"
34 #include "sync/internal_api/public/read_node.h" 33 #include "sync/internal_api/public/read_node.h"
35 #include "sync/internal_api/public/read_transaction.h" 34 #include "sync/internal_api/public/read_transaction.h"
36 #include "sync/internal_api/public/test/test_entry_factory.h" 35 #include "sync/internal_api/public/test/test_entry_factory.h"
37 #include "sync/internal_api/public/test/test_internal_components_factory.h" 36 #include "sync/internal_api/public/test/test_internal_components_factory.h"
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 this, 828 this,
830 credentials, 829 credentials,
831 "fake_invalidator_client_id", 830 "fake_invalidator_client_id",
832 std::string(), 831 std::string(),
833 std::string(), // bootstrap tokens 832 std::string(), // bootstrap tokens
834 scoped_ptr<InternalComponentsFactory>(GetFactory()).get(), 833 scoped_ptr<InternalComponentsFactory>(GetFactory()).get(),
835 &encryptor_, 834 &encryptor_,
836 scoped_ptr<UnrecoverableErrorHandler>( 835 scoped_ptr<UnrecoverableErrorHandler>(
837 new TestUnrecoverableErrorHandler).Pass(), 836 new TestUnrecoverableErrorHandler).Pass(),
838 NULL, 837 NULL,
839 false, 838 false);
840 &cancelation_signal_);
841 839
842 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_); 840 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_);
843 841
844 EXPECT_TRUE(js_backend_.IsInitialized()); 842 EXPECT_TRUE(js_backend_.IsInitialized());
845 843
846 for (ModelSafeRoutingInfo::iterator i = routing_info.begin(); 844 for (ModelSafeRoutingInfo::iterator i = routing_info.begin();
847 i != routing_info.end(); ++i) { 845 i != routing_info.end(); ++i) {
848 type_roots_[i->first] = MakeServerNodeForType( 846 type_roots_[i->first] = MakeServerNodeForType(
849 sync_manager_.GetUserShare(), i->first); 847 sync_manager_.GetUserShare(), i->first);
850 } 848 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 base::MessageLoop message_loop_; 1011 base::MessageLoop message_loop_;
1014 // Needed by |sync_manager_|. 1012 // Needed by |sync_manager_|.
1015 base::ScopedTempDir temp_dir_; 1013 base::ScopedTempDir temp_dir_;
1016 // Sync Id's for the roots of the enabled datatypes. 1014 // Sync Id's for the roots of the enabled datatypes.
1017 std::map<ModelType, int64> type_roots_; 1015 std::map<ModelType, int64> type_roots_;
1018 scoped_refptr<ExtensionsActivity> extensions_activity_; 1016 scoped_refptr<ExtensionsActivity> extensions_activity_;
1019 1017
1020 protected: 1018 protected:
1021 FakeEncryptor encryptor_; 1019 FakeEncryptor encryptor_;
1022 SyncManagerImpl sync_manager_; 1020 SyncManagerImpl sync_manager_;
1023 CancelationSignal cancelation_signal_;
1024 WeakHandle<JsBackend> js_backend_; 1021 WeakHandle<JsBackend> js_backend_;
1025 StrictMock<SyncManagerObserverMock> manager_observer_; 1022 StrictMock<SyncManagerObserverMock> manager_observer_;
1026 StrictMock<SyncEncryptionHandlerObserverMock> encryption_observer_; 1023 StrictMock<SyncEncryptionHandlerObserverMock> encryption_observer_;
1027 InternalComponentsFactory::Switches switches_; 1024 InternalComponentsFactory::Switches switches_;
1028 }; 1025 };
1029 1026
1030 TEST_F(SyncManagerTest, ProcessJsMessage) { 1027 TEST_F(SyncManagerTest, ProcessJsMessage) {
1031 const JsArgList kNoArgs; 1028 const JsArgList kNoArgs;
1032 1029
1033 StrictMock<MockJsReplyHandler> reply_handler; 1030 StrictMock<MockJsReplyHandler> reply_handler;
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
2792 ComponentsFactory(const Switches& switches, 2789 ComponentsFactory(const Switches& switches,
2793 SyncScheduler* scheduler_to_use, 2790 SyncScheduler* scheduler_to_use,
2794 sessions::SyncSessionContext** session_context) 2791 sessions::SyncSessionContext** session_context)
2795 : TestInternalComponentsFactory(switches, syncer::STORAGE_IN_MEMORY), 2792 : TestInternalComponentsFactory(switches, syncer::STORAGE_IN_MEMORY),
2796 scheduler_to_use_(scheduler_to_use), 2793 scheduler_to_use_(scheduler_to_use),
2797 session_context_(session_context) {} 2794 session_context_(session_context) {}
2798 virtual ~ComponentsFactory() {} 2795 virtual ~ComponentsFactory() {}
2799 2796
2800 virtual scoped_ptr<SyncScheduler> BuildScheduler( 2797 virtual scoped_ptr<SyncScheduler> BuildScheduler(
2801 const std::string& name, 2798 const std::string& name,
2802 sessions::SyncSessionContext* context, 2799 sessions::SyncSessionContext* context) OVERRIDE {
2803 CancelationSignal* stop_handle) OVERRIDE {
2804 *session_context_ = context; 2800 *session_context_ = context;
2805 return scheduler_to_use_.Pass(); 2801 return scheduler_to_use_.Pass();
2806 } 2802 }
2807 2803
2808 private: 2804 private:
2809 scoped_ptr<SyncScheduler> scheduler_to_use_; 2805 scoped_ptr<SyncScheduler> scheduler_to_use_;
2810 sessions::SyncSessionContext** session_context_; 2806 sessions::SyncSessionContext** session_context_;
2811 }; 2807 };
2812 2808
2813 class SyncManagerTestWithMockScheduler : public SyncManagerTest { 2809 class SyncManagerTestWithMockScheduler : public SyncManagerTest {
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 size_t folder_b_pos = 3508 size_t folder_b_pos =
3513 FindChangeInList(folder_b_id, ChangeRecord::ACTION_DELETE); 3509 FindChangeInList(folder_b_id, ChangeRecord::ACTION_DELETE);
3514 size_t child_pos = FindChangeInList(child_id, ChangeRecord::ACTION_DELETE); 3510 size_t child_pos = FindChangeInList(child_id, ChangeRecord::ACTION_DELETE);
3515 3511
3516 // Deletes should appear before updates. 3512 // Deletes should appear before updates.
3517 EXPECT_LT(child_pos, folder_a_pos); 3513 EXPECT_LT(child_pos, folder_a_pos);
3518 EXPECT_LT(folder_b_pos, folder_a_pos); 3514 EXPECT_LT(folder_b_pos, folder_a_pos);
3519 } 3515 }
3520 3516
3521 } // namespace 3517 } // namespace
OLDNEW
« no previous file with comments | « trunk/src/sync/internal_api/sync_manager_impl.cc ('k') | trunk/src/sync/internal_api/syncapi_server_connection_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698