Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 ASSERT_LT(0, c.Get(BASE_VERSION)); | 371 ASSERT_LT(0, c.Get(BASE_VERSION)); |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 cid = c.Get(syncable::NEXT_ID); | 374 cid = c.Get(syncable::NEXT_ID); |
| 375 child_count++; | 375 child_count++; |
| 376 } | 376 } |
| 377 ASSERT_EQ(batch_size*2, child_count) | 377 ASSERT_EQ(batch_size*2, child_count) |
| 378 << "Too few or too many children in parent folder after commit."; | 378 << "Too few or too many children in parent folder after commit."; |
| 379 } | 379 } |
| 380 | 380 |
| 381 TEST_F(ProcessCommitResponseCommandTest, BagOfChipsPersistence) { | |
| 382 sessions::OrderedCommitSet commit_set(session()->routing_info()); | |
| 383 sync_pb::ClientToServerMessage request; | |
| 384 sync_pb::ClientToServerResponse& response = | |
|
Nicolas Zea
2012/09/07 18:38:43
nit: make pointer (references should always be con
qsr
2012/09/10 08:12:37
Done.
| |
| 385 const_cast<sync_pb::ClientToServerResponse&>( | |
| 386 session()->status_controller().updates_response()); | |
|
Nicolas Zea
2012/09/07 18:38:43
use mutable_updates_response() instead of const_ca
qsr
2012/09/10 08:12:37
Problem is that status_controller is a const metho
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |