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

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

Issue 10916174: Implement a bag of chips for sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review 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
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 #include "sync/engine/process_commit_response_command.h" 5 #include "sync/engine/process_commit_response_command.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 10 matching lines...) Expand all
21 #include "sync/test/engine/syncer_command_test.h" 21 #include "sync/test/engine/syncer_command_test.h"
22 #include "sync/test/engine/test_id_factory.h" 22 #include "sync/test/engine/test_id_factory.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 using std::string; 25 using std::string;
26 using sync_pb::ClientToServerMessage; 26 using sync_pb::ClientToServerMessage;
27 using sync_pb::CommitResponse; 27 using sync_pb::CommitResponse;
28 28
29 namespace syncer { 29 namespace syncer {
30 30
31 using sessions::StatusController;
31 using sessions::SyncSession; 32 using sessions::SyncSession;
32 using syncable::BASE_VERSION; 33 using syncable::BASE_VERSION;
33 using syncable::Entry; 34 using syncable::Entry;
34 using syncable::IS_DIR; 35 using syncable::IS_DIR;
35 using syncable::IS_UNSYNCED; 36 using syncable::IS_UNSYNCED;
36 using syncable::Id; 37 using syncable::Id;
37 using syncable::MutableEntry; 38 using syncable::MutableEntry;
38 using syncable::NON_UNIQUE_NAME; 39 using syncable::NON_UNIQUE_NAME;
39 using syncable::UNITTEST; 40 using syncable::UNITTEST;
40 using syncable::WriteTransaction; 41 using syncable::WriteTransaction;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 ASSERT_LT(0, c.Get(BASE_VERSION)); 372 ASSERT_LT(0, c.Get(BASE_VERSION));
372 } 373 }
373 } 374 }
374 cid = c.Get(syncable::NEXT_ID); 375 cid = c.Get(syncable::NEXT_ID);
375 child_count++; 376 child_count++;
376 } 377 }
377 ASSERT_EQ(batch_size*2, child_count) 378 ASSERT_EQ(batch_size*2, child_count)
378 << "Too few or too many children in parent folder after commit."; 379 << "Too few or too many children in parent folder after commit.";
379 } 380 }
380 381
382 TEST_F(ProcessCommitResponseCommandTest, BagOfChipsPersistence) {
383 sessions::OrderedCommitSet commit_set(session()->routing_info());
384 sync_pb::ClientToServerMessage request;
385 sync_pb::ClientToServerResponse* response = const_cast<StatusController&>(
386 session()->status_controller()).mutable_updates_response();
387
388 sync_pb::ClientToServerResponse random_message;
389 random_message.set_error_message("hello");
390 random_message.set_store_birthday("world");
391 std::string serialized_message;
392 random_message.SerializeToString(&serialized_message);
393 // Bag Of Chips must be allowed to be extended by the server without the
394 // client noticing. Using a random message for it is a way to check that it is
395 // possible.
396 response->mutable_new_bag_of_chips()->ParseFromString(serialized_message);
397
398 ProcessCommitResponseCommand command(commit_set, request, *response);
399 command.ExecuteImpl(session());
400 EXPECT_EQ(serialized_message, directory()->bag_of_chips());
401 }
402
381 // This test fixture runs across a Cartesian product of per-type fail/success 403 // This test fixture runs across a Cartesian product of per-type fail/success
382 // possibilities. 404 // possibilities.
383 enum { 405 enum {
384 TEST_PARAM_BOOKMARK_ENABLE_BIT, 406 TEST_PARAM_BOOKMARK_ENABLE_BIT,
385 TEST_PARAM_AUTOFILL_ENABLE_BIT, 407 TEST_PARAM_AUTOFILL_ENABLE_BIT,
386 TEST_PARAM_BIT_COUNT 408 TEST_PARAM_BIT_COUNT
387 }; 409 };
388 class MixedResult : 410 class MixedResult :
389 public ProcessCommitResponseCommandTest, 411 public ProcessCommitResponseCommandTest,
390 public ::testing::WithParamInterface<int> { 412 public ::testing::WithParamInterface<int> {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 470 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
449 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 471 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
450 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 472 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
451 } else { 473 } else {
452 EXPECT_TRUE(final_monitor_records.empty()) 474 EXPECT_TRUE(final_monitor_records.empty())
453 << "Should not restore records after successful bookmark commit."; 475 << "Should not restore records after successful bookmark commit.";
454 } 476 }
455 } 477 }
456 478
457 } // namespace syncer 479 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698