| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/sync/engine/download_updates_command.h" | 5 #include "chrome/browser/sync/engine/download_updates_command.h" |
| 6 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" | 6 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" |
| 7 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 7 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
| 8 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" | 8 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" |
| 9 #include "chrome/browser/sync/protocol/sync.pb.h" | 9 #include "chrome/browser/sync/protocol/sync.pb.h" |
| 10 #include "chrome/browser/sync/syncable/directory_manager.h" | 10 #include "chrome/browser/sync/syncable/directory_manager.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 syncable::ModelTypeBitSet enabled_types; | 80 syncable::ModelTypeBitSet enabled_types; |
| 81 enabled_types[syncable::PREFERENCES] = true; | 81 enabled_types[syncable::PREFERENCES] = true; |
| 82 sync_pb::EntitySpecifics get_updates_filter; | 82 sync_pb::EntitySpecifics get_updates_filter; |
| 83 command_.SetRequestedTypes(enabled_types, &get_updates_filter); | 83 command_.SetRequestedTypes(enabled_types, &get_updates_filter); |
| 84 ProtoExtensionValidator<sync_pb::EntitySpecifics> v(get_updates_filter); | 84 ProtoExtensionValidator<sync_pb::EntitySpecifics> v(get_updates_filter); |
| 85 v.ExpectHasExtension(sync_pb::preference); | 85 v.ExpectHasExtension(sync_pb::preference); |
| 86 v.ExpectNoOtherFieldsOrExtensions(); | 86 v.ExpectNoOtherFieldsOrExtensions(); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 TEST_F(DownloadUpdatesCommandTest, OldestTimestampPicked) { | |
| 91 syncable::ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | |
| 92 ASSERT_TRUE(dir.good()); | |
| 93 | |
| 94 // i,j,k range over every possible model type. j and k are enabled and at | |
| 95 // the same timestamp. if i != j or k, i is enabled but at an older | |
| 96 // timestamp. | |
| 97 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | |
| 98 syncable::ModelType type_i = syncable::ModelTypeFromInt(i); | |
| 99 for (int j = FIRST_REAL_MODEL_TYPE; j < MODEL_TYPE_COUNT; ++j) { | |
| 100 syncable::ModelType type_j = syncable::ModelTypeFromInt(j); | |
| 101 for (int k = FIRST_REAL_MODEL_TYPE; k < MODEL_TYPE_COUNT; ++k) { | |
| 102 syncable::ModelType type_k = syncable::ModelTypeFromInt(k); | |
| 103 SCOPED_TRACE(testing::Message() << "Iteration (" << i << "," << j | |
| 104 << "," << k << ")"); | |
| 105 mutable_routing_info()->clear(); | |
| 106 (*mutable_routing_info())[type_i] = browser_sync::GROUP_UI; | |
| 107 (*mutable_routing_info())[type_j] = browser_sync::GROUP_DB; | |
| 108 (*mutable_routing_info())[type_k] = browser_sync::GROUP_UI; | |
| 109 dir->set_last_download_timestamp(type_i, 5000 + j); | |
| 110 dir->set_last_download_timestamp(type_j, 1000 + i); | |
| 111 dir->set_last_download_timestamp(type_k, 1000 + i); | |
| 112 | |
| 113 ConfigureMockServerConnection(); | |
| 114 dir->set_store_birthday(mock_server()->store_birthday()); | |
| 115 | |
| 116 syncable::ModelTypeBitSet expected_request_types; | |
| 117 expected_request_types[j] = true; | |
| 118 expected_request_types[k] = true; | |
| 119 mock_server()->ExpectGetUpdatesRequestTypes(expected_request_types); | |
| 120 | |
| 121 command_.Execute(session()); | |
| 122 | |
| 123 const sync_pb::ClientToServerMessage& r = mock_server()->last_request(); | |
| 124 EXPECT_EQ(1, mock_server()->GetAndClearNumGetUpdatesRequests()); | |
| 125 EXPECT_TRUE(r.has_get_updates()); | |
| 126 EXPECT_TRUE(r.get_updates().has_from_timestamp()); | |
| 127 EXPECT_EQ(1000 + i, r.get_updates().from_timestamp()); | |
| 128 EXPECT_TRUE(r.get_updates().has_fetch_folders()); | |
| 129 EXPECT_TRUE(r.get_updates().fetch_folders()); | |
| 130 EXPECT_TRUE(r.get_updates().has_requested_types()); | |
| 131 } | |
| 132 } | |
| 133 } | |
| 134 } | |
| 135 | |
| 136 } // namespace browser_sync | 90 } // namespace browser_sync |
| OLD | NEW |