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

Side by Side Diff: components/sync/engine_impl/syncer_unittest.cc

Issue 2718533003: [Sync] Adjust types to configure during shutdown (Closed)
Patch Set: Add syncer unittest Created 3 years, 10 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 | « components/sync/engine_impl/syncer.cc ('k') | no next file » | 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 #include "components/sync/engine_impl/syncer.h" 5 #include "components/sync/engine_impl/syncer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 ResetCycle(); 244 ResetCycle();
245 245
246 // Pretend we've seen a local change, to make the nudge_tracker look normal. 246 // Pretend we've seen a local change, to make the nudge_tracker look normal.
247 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); 247 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS));
248 248
249 return syncer_->NormalSyncShare(context_->GetEnabledTypes(), 249 return syncer_->NormalSyncShare(context_->GetEnabledTypes(),
250 &nudge_tracker_, cycle_.get()); 250 &nudge_tracker_, cycle_.get());
251 } 251 }
252 252
253 bool SyncShareConfigure() { 253 bool SyncShareConfigure() {
254 return SyncShareConfigureTypes(context_->GetEnabledTypes());
255 }
256
257 bool SyncShareConfigureTypes(ModelTypeSet types) {
254 ResetCycle(); 258 ResetCycle();
255 return syncer_->ConfigureSyncShare( 259 return syncer_->ConfigureSyncShare(
256 context_->GetEnabledTypes(), 260 types, sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, cycle_.get());
257 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, cycle_.get());
258 } 261 }
259 262
260 void SetUp() override { 263 void SetUp() override {
261 test_user_share_.SetUp(); 264 test_user_share_.SetUp();
262 mock_server_ = base::MakeUnique<MockConnectionManager>( 265 mock_server_ = base::MakeUnique<MockConnectionManager>(
263 directory(), &cancelation_signal_); 266 directory(), &cancelation_signal_);
264 debug_info_getter_ = base::MakeUnique<MockDebugInfoGetter>(); 267 debug_info_getter_ = base::MakeUnique<MockDebugInfoGetter>();
265 workers_.push_back( 268 workers_.push_back(
266 scoped_refptr<ModelSafeWorker>(new FakeModelWorker(GROUP_PASSIVE))); 269 scoped_refptr<ModelSafeWorker>(new FakeModelWorker(GROUP_PASSIVE)));
267 std::vector<SyncEngineEventListener*> listeners; 270 std::vector<SyncEngineEventListener*> listeners;
(...skipping 4744 matching lines...) Expand 10 before | Expand all | Expand 10 after
5012 EXPECT_TRUE(n1.GetIsUnappliedUpdate()); 5015 EXPECT_TRUE(n1.GetIsUnappliedUpdate());
5013 5016
5014 // The second node was not downloaded. 5017 // The second node was not downloaded.
5015 Entry n2(&trans, GET_BY_ID, node2); 5018 Entry n2(&trans, GET_BY_ID, node2);
5016 EXPECT_FALSE(n2.good()); 5019 EXPECT_FALSE(n2.good());
5017 5020
5018 // One update remains undownloaded. 5021 // One update remains undownloaded.
5019 mock_server_->ClearUpdatesQueue(); 5022 mock_server_->ClearUpdatesQueue();
5020 } 5023 }
5021 5024
5025 // Tests that, after shutdown initiated, if set of types to download includes
5026 // unregistered type, DCHECK doesn't get triggered.
5027 TEST_F(SyncerTest, ConfigureUnregisteredTypesDuringShutdown) {
5028 // Signal that shutdown is initiated.
5029 cancelation_signal_.Signal();
5030
5031 // Simulate type being unregistered before configuration by including type
5032 // that isn't registered with ModelTypeRegistry.
5033 SyncShareConfigureTypes(ModelTypeSet(APPS));
5034
5035 // No explicit verification, DCHECK shouldn't have been triggered.
5036 }
5037
5022 TEST_F(SyncerTest, GetKeySuccess) { 5038 TEST_F(SyncerTest, GetKeySuccess) {
5023 { 5039 {
5024 syncable::ReadTransaction rtrans(FROM_HERE, directory()); 5040 syncable::ReadTransaction rtrans(FROM_HERE, directory());
5025 EXPECT_TRUE(directory()->GetNigoriHandler()->NeedKeystoreKey(&rtrans)); 5041 EXPECT_TRUE(directory()->GetNigoriHandler()->NeedKeystoreKey(&rtrans));
5026 } 5042 }
5027 5043
5028 SyncShareConfigure(); 5044 SyncShareConfigure();
5029 5045
5030 EXPECT_EQ(SYNCER_OK, cycle_->status_controller().last_get_key_result()); 5046 EXPECT_EQ(SYNCER_OK, cycle_->status_controller().last_get_key_result());
5031 { 5047 {
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
5893 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 5909 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
5894 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 5910 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
5895 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 5911 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
5896 } else { 5912 } else {
5897 EXPECT_TRUE(final_monitor_records.empty()) 5913 EXPECT_TRUE(final_monitor_records.empty())
5898 << "Should not restore records after successful bookmark commit."; 5914 << "Should not restore records after successful bookmark commit.";
5899 } 5915 }
5900 } 5916 }
5901 5917
5902 } // namespace syncer 5918 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/syncer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698