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 // Unit tests for the SyncApi. Note that a lot of the underlying | 5 // Unit tests for the SyncApi. Note that a lot of the underlying |
6 // functionality is provided by the Syncable layer, which has its own | 6 // functionality is provided by the Syncable layer, which has its own |
7 // unit tests. We'll test SyncApi specific things in this harness. | 7 // unit tests. We'll test SyncApi specific things in this harness. |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 2549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2560 base::Bind(&CallbackCounter::Callback, | 2560 base::Bind(&CallbackCounter::Callback, |
2561 base::Unretained(&retry_task_counter))); | 2561 base::Unretained(&retry_task_counter))); |
2562 EXPECT_EQ(0, ready_task_counter.times_called()); | 2562 EXPECT_EQ(0, ready_task_counter.times_called()); |
2563 EXPECT_EQ(1, retry_task_counter.times_called()); | 2563 EXPECT_EQ(1, retry_task_counter.times_called()); |
2564 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, | 2564 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, |
2565 params.source); | 2565 params.source); |
2566 EXPECT_TRUE(types_to_download.Equals(params.types_to_download)); | 2566 EXPECT_TRUE(types_to_download.Equals(params.types_to_download)); |
2567 EXPECT_EQ(new_routing_info, params.routing_info); | 2567 EXPECT_EQ(new_routing_info, params.routing_info); |
2568 } | 2568 } |
2569 | 2569 |
| 2570 // Test that PurgePartiallySyncedTypes purges only those types that don't |
| 2571 // have empty progress marker and don't have initial sync ended set. |
| 2572 TEST_F(SyncManagerTest, PurgePartiallySyncedTypes) { |
| 2573 UserShare* share = sync_manager_.GetUserShare(); |
| 2574 |
| 2575 // Set Nigori and Bookmarks to be partial types. |
| 2576 sync_pb::DataTypeProgressMarker nigori_marker; |
| 2577 nigori_marker.set_data_type_id( |
| 2578 GetSpecificsFieldNumberFromModelType(NIGORI)); |
| 2579 nigori_marker.set_token("token"); |
| 2580 sync_pb::DataTypeProgressMarker bookmark_marker; |
| 2581 bookmark_marker.set_data_type_id( |
| 2582 GetSpecificsFieldNumberFromModelType(BOOKMARKS)); |
| 2583 bookmark_marker.set_token("token"); |
| 2584 share->directory->SetDownloadProgress(NIGORI, nigori_marker); |
| 2585 share->directory->SetDownloadProgress(BOOKMARKS, bookmark_marker); |
| 2586 |
| 2587 // Set Preferences to be a full type. |
| 2588 sync_pb::DataTypeProgressMarker pref_marker; |
| 2589 pref_marker.set_data_type_id( |
| 2590 GetSpecificsFieldNumberFromModelType(PREFERENCES)); |
| 2591 pref_marker.set_token("token"); |
| 2592 share->directory->SetDownloadProgress(PREFERENCES, pref_marker); |
| 2593 share->directory->set_initial_sync_ended_for_type(PREFERENCES, true); |
| 2594 |
| 2595 ModelTypeSet partial_types = |
| 2596 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()); |
| 2597 EXPECT_FALSE(partial_types.Has(NIGORI)); |
| 2598 EXPECT_FALSE(partial_types.Has(BOOKMARKS)); |
| 2599 EXPECT_FALSE(partial_types.Has(PREFERENCES)); |
| 2600 |
| 2601 EXPECT_TRUE(sync_manager_.PurgePartiallySyncedTypes()); |
| 2602 |
| 2603 // Ensure only bookmarks and nigori lost their progress marker. Preferences |
| 2604 // should still have it. |
| 2605 partial_types = |
| 2606 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()); |
| 2607 EXPECT_TRUE(partial_types.Has(NIGORI)); |
| 2608 EXPECT_TRUE(partial_types.Has(BOOKMARKS)); |
| 2609 EXPECT_FALSE(partial_types.Has(PREFERENCES)); |
| 2610 } |
| 2611 |
2570 } // namespace | 2612 } // namespace |
OLD | NEW |