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

Side by Side Diff: sync/engine/syncer_unittest.cc

Issue 10909160: sync: Process client commands on commit response (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Inline client command processing Created 8 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
« no previous file with comments | « sync/engine/syncer_proto_util.cc ('k') | sync/test/engine/mock_connection_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 (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 // Syncer unit tests. Unfortunately a lot of these tests 5 // Syncer unit tests. Unfortunately a lot of these tests
6 // are outdated and need to be reworked and updated. 6 // are outdated and need to be reworked and updated.
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <limits> 9 #include <limits>
10 #include <list> 10 #include <list>
(...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after
3334 EXPECT_NE(foo_entry.Get(syncable::ID), in_root_id); 3334 EXPECT_NE(foo_entry.Get(syncable::ID), in_root_id);
3335 3335
3336 Entry bar_entry(&trans, GET_BY_HANDLE, bar_metahandle); 3336 Entry bar_entry(&trans, GET_BY_HANDLE, bar_metahandle);
3337 ASSERT_TRUE(bar_entry.good()); 3337 ASSERT_TRUE(bar_entry.good());
3338 EXPECT_EQ("bar", bar_entry.Get(NON_UNIQUE_NAME)); 3338 EXPECT_EQ("bar", bar_entry.Get(NON_UNIQUE_NAME));
3339 EXPECT_NE(bar_entry.Get(syncable::ID), in_dir_id); 3339 EXPECT_NE(bar_entry.Get(syncable::ID), in_dir_id);
3340 EXPECT_EQ(foo_entry.Get(syncable::ID), bar_entry.Get(PARENT_ID)); 3340 EXPECT_EQ(foo_entry.Get(syncable::ID), bar_entry.Get(PARENT_ID));
3341 } 3341 }
3342 } 3342 }
3343 3343
3344 TEST_F(SyncerTest, TestClientCommand) { 3344 TEST_F(SyncerTest, TestClientCommandDuringUpdate) {
3345 using sync_pb::ClientCommand; 3345 using sync_pb::ClientCommand;
3346 3346
3347 ClientCommand* command = mock_server_->GetNextClientCommand(); 3347 ClientCommand* command = new ClientCommand();
3348 command->set_set_sync_poll_interval(8); 3348 command->set_set_sync_poll_interval(8);
3349 command->set_set_sync_long_poll_interval(800); 3349 command->set_set_sync_long_poll_interval(800);
3350 command->set_sessions_commit_delay_seconds(3141); 3350 command->set_sessions_commit_delay_seconds(3141);
3351 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); 3351 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1);
3352 mock_server_->SetGUClientCommand(command);
3352 SyncShareNudge(); 3353 SyncShareNudge();
3353 3354
3354 EXPECT_TRUE(TimeDelta::FromSeconds(8) == 3355 EXPECT_TRUE(TimeDelta::FromSeconds(8) ==
3355 last_short_poll_interval_received_); 3356 last_short_poll_interval_received_);
3356 EXPECT_TRUE(TimeDelta::FromSeconds(800) == 3357 EXPECT_TRUE(TimeDelta::FromSeconds(800) ==
3357 last_long_poll_interval_received_); 3358 last_long_poll_interval_received_);
3358 EXPECT_TRUE(TimeDelta::FromSeconds(3141) == 3359 EXPECT_TRUE(TimeDelta::FromSeconds(3141) ==
3359 last_sessions_commit_delay_seconds_); 3360 last_sessions_commit_delay_seconds_);
3360 3361
3361 command = mock_server_->GetNextClientCommand(); 3362 command = new ClientCommand();
3362 command->set_set_sync_poll_interval(180); 3363 command->set_set_sync_poll_interval(180);
3363 command->set_set_sync_long_poll_interval(190); 3364 command->set_set_sync_long_poll_interval(190);
3364 command->set_sessions_commit_delay_seconds(2718); 3365 command->set_sessions_commit_delay_seconds(2718);
3365 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); 3366 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1);
3367 mock_server_->SetGUClientCommand(command);
3366 SyncShareNudge(); 3368 SyncShareNudge();
3367 3369
3368 EXPECT_TRUE(TimeDelta::FromSeconds(180) == 3370 EXPECT_TRUE(TimeDelta::FromSeconds(180) ==
3371 last_short_poll_interval_received_);
3372 EXPECT_TRUE(TimeDelta::FromSeconds(190) ==
3373 last_long_poll_interval_received_);
3374 EXPECT_TRUE(TimeDelta::FromSeconds(2718) ==
3375 last_sessions_commit_delay_seconds_);
3376 }
3377
3378 TEST_F(SyncerTest, TestClientCommandDuringCommit) {
3379 using sync_pb::ClientCommand;
3380
3381 ClientCommand* command = new ClientCommand();
3382 command->set_set_sync_poll_interval(8);
3383 command->set_set_sync_long_poll_interval(800);
3384 command->set_sessions_commit_delay_seconds(3141);
3385 CreateUnsyncedDirectory("X", "id_X");
3386 mock_server_->SetCommitClientCommand(command);
3387 SyncShareNudge();
3388
3389 EXPECT_TRUE(TimeDelta::FromSeconds(8) ==
3390 last_short_poll_interval_received_);
3391 EXPECT_TRUE(TimeDelta::FromSeconds(800) ==
3392 last_long_poll_interval_received_);
3393 EXPECT_TRUE(TimeDelta::FromSeconds(3141) ==
3394 last_sessions_commit_delay_seconds_);
3395
3396 command = new ClientCommand();
3397 command->set_set_sync_poll_interval(180);
3398 command->set_set_sync_long_poll_interval(190);
3399 command->set_sessions_commit_delay_seconds(2718);
3400 CreateUnsyncedDirectory("Y", "id_Y");
3401 mock_server_->SetCommitClientCommand(command);
3402 SyncShareNudge();
3403
3404 EXPECT_TRUE(TimeDelta::FromSeconds(180) ==
3369 last_short_poll_interval_received_); 3405 last_short_poll_interval_received_);
3370 EXPECT_TRUE(TimeDelta::FromSeconds(190) == 3406 EXPECT_TRUE(TimeDelta::FromSeconds(190) ==
3371 last_long_poll_interval_received_); 3407 last_long_poll_interval_received_);
3372 EXPECT_TRUE(TimeDelta::FromSeconds(2718) == 3408 EXPECT_TRUE(TimeDelta::FromSeconds(2718) ==
3373 last_sessions_commit_delay_seconds_); 3409 last_sessions_commit_delay_seconds_);
3374 } 3410 }
3375 3411
3376 TEST_F(SyncerTest, EnsureWeSendUpOldParent) { 3412 TEST_F(SyncerTest, EnsureWeSendUpOldParent) {
3377 syncable::Id folder_one_id = ids_.FromNumber(1); 3413 syncable::Id folder_one_id = ids_.FromNumber(1);
3378 syncable::Id folder_two_id = ids_.FromNumber(2); 3414 syncable::Id folder_two_id = ids_.FromNumber(2);
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
4779 4815
4780 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { 4816 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) {
4781 Add(mid_id_); 4817 Add(mid_id_);
4782 Add(low_id_); 4818 Add(low_id_);
4783 Add(high_id_); 4819 Add(high_id_);
4784 SyncShareNudge(); 4820 SyncShareNudge();
4785 ExpectLocalOrderIsByServerId(); 4821 ExpectLocalOrderIsByServerId();
4786 } 4822 }
4787 4823
4788 } // namespace syncer 4824 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer_proto_util.cc ('k') | sync/test/engine/mock_connection_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698