| 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 "components/sync/sessions/sync_session_snapshot.h" | 5 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/test/values_test_util.h" | 10 #include "base/test/values_test_util.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace syncer { | 14 namespace syncer { |
| 15 namespace sessions { | |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| 18 using base::ExpectDictBooleanValue; | 17 using base::ExpectDictBooleanValue; |
| 19 using base::ExpectDictDictionaryValue; | 18 using base::ExpectDictDictionaryValue; |
| 20 using base::ExpectDictIntegerValue; | 19 using base::ExpectDictIntegerValue; |
| 21 using base::ExpectDictListValue; | 20 using base::ExpectDictListValue; |
| 22 using base::ExpectDictStringValue; | 21 using base::ExpectDictStringValue; |
| 23 | 22 |
| 24 class SyncSessionSnapshotTest : public testing::Test {}; | 23 class SyncCycleSnapshotTest : public testing::Test {}; |
| 25 | 24 |
| 26 TEST_F(SyncSessionSnapshotTest, SyncSessionSnapshotToValue) { | 25 TEST_F(SyncCycleSnapshotTest, SyncCycleSnapshotToValue) { |
| 27 ModelNeutralState model_neutral; | 26 ModelNeutralState model_neutral; |
| 28 model_neutral.num_successful_commits = 5; | 27 model_neutral.num_successful_commits = 5; |
| 29 model_neutral.num_successful_bookmark_commits = 10; | 28 model_neutral.num_successful_bookmark_commits = 10; |
| 30 model_neutral.num_updates_downloaded_total = 100; | 29 model_neutral.num_updates_downloaded_total = 100; |
| 31 model_neutral.num_tombstone_updates_downloaded_total = 200; | 30 model_neutral.num_tombstone_updates_downloaded_total = 200; |
| 32 model_neutral.num_reflected_updates_downloaded_total = 50; | 31 model_neutral.num_reflected_updates_downloaded_total = 50; |
| 33 model_neutral.num_local_overwrites = 15; | 32 model_neutral.num_local_overwrites = 15; |
| 34 model_neutral.num_server_overwrites = 18; | 33 model_neutral.num_server_overwrites = 18; |
| 35 | 34 |
| 36 ProgressMarkerMap download_progress_markers; | 35 ProgressMarkerMap download_progress_markers; |
| 37 download_progress_markers[BOOKMARKS] = "\xef\xb7\xa4"; | 36 download_progress_markers[BOOKMARKS] = "\xef\xb7\xa4"; |
| 38 download_progress_markers[APPS] = "apps"; | 37 download_progress_markers[APPS] = "apps"; |
| 39 std::unique_ptr<base::DictionaryValue> | 38 std::unique_ptr<base::DictionaryValue> |
| 40 expected_download_progress_markers_value( | 39 expected_download_progress_markers_value( |
| 41 ProgressMarkerMapToValue(download_progress_markers)); | 40 ProgressMarkerMapToValue(download_progress_markers)); |
| 42 | 41 |
| 43 const bool kIsSilenced = true; | 42 const bool kIsSilenced = true; |
| 44 const int kNumEncryptionConflicts = 1054; | 43 const int kNumEncryptionConflicts = 1054; |
| 45 const int kNumHierarchyConflicts = 1055; | 44 const int kNumHierarchyConflicts = 1055; |
| 46 const int kNumServerConflicts = 1057; | 45 const int kNumServerConflicts = 1057; |
| 47 | 46 |
| 48 SyncSessionSnapshot snapshot(model_neutral, download_progress_markers, | 47 SyncCycleSnapshot snapshot(model_neutral, download_progress_markers, |
| 49 kIsSilenced, kNumEncryptionConflicts, | 48 kIsSilenced, kNumEncryptionConflicts, |
| 50 kNumHierarchyConflicts, kNumServerConflicts, | 49 kNumHierarchyConflicts, kNumServerConflicts, false, |
| 51 false, 0, base::Time::Now(), base::Time::Now(), | 50 0, base::Time::Now(), base::Time::Now(), |
| 52 std::vector<int>(MODEL_TYPE_COUNT, 0), | 51 std::vector<int>(MODEL_TYPE_COUNT, 0), |
| 53 std::vector<int>(MODEL_TYPE_COUNT, 0), | 52 std::vector<int>(MODEL_TYPE_COUNT, 0), |
| 54 sync_pb::GetUpdatesCallerInfo::UNKNOWN); | 53 sync_pb::GetUpdatesCallerInfo::UNKNOWN); |
| 55 std::unique_ptr<base::DictionaryValue> value(snapshot.ToValue()); | 54 std::unique_ptr<base::DictionaryValue> value(snapshot.ToValue()); |
| 56 EXPECT_EQ(16u, value->size()); | 55 EXPECT_EQ(16u, value->size()); |
| 57 ExpectDictIntegerValue(model_neutral.num_successful_commits, *value, | 56 ExpectDictIntegerValue(model_neutral.num_successful_commits, *value, |
| 58 "numSuccessfulCommits"); | 57 "numSuccessfulCommits"); |
| 59 ExpectDictIntegerValue(model_neutral.num_successful_bookmark_commits, *value, | 58 ExpectDictIntegerValue(model_neutral.num_successful_bookmark_commits, *value, |
| 60 "numSuccessfulBookmarkCommits"); | 59 "numSuccessfulBookmarkCommits"); |
| 61 ExpectDictIntegerValue(model_neutral.num_updates_downloaded_total, *value, | 60 ExpectDictIntegerValue(model_neutral.num_updates_downloaded_total, *value, |
| 62 "numUpdatesDownloadedTotal"); | 61 "numUpdatesDownloadedTotal"); |
| 63 ExpectDictIntegerValue(model_neutral.num_tombstone_updates_downloaded_total, | 62 ExpectDictIntegerValue(model_neutral.num_tombstone_updates_downloaded_total, |
| 64 *value, "numTombstoneUpdatesDownloadedTotal"); | 63 *value, "numTombstoneUpdatesDownloadedTotal"); |
| 65 ExpectDictIntegerValue(model_neutral.num_reflected_updates_downloaded_total, | 64 ExpectDictIntegerValue(model_neutral.num_reflected_updates_downloaded_total, |
| 66 *value, "numReflectedUpdatesDownloadedTotal"); | 65 *value, "numReflectedUpdatesDownloadedTotal"); |
| 67 ExpectDictIntegerValue(model_neutral.num_local_overwrites, *value, | 66 ExpectDictIntegerValue(model_neutral.num_local_overwrites, *value, |
| 68 "numLocalOverwrites"); | 67 "numLocalOverwrites"); |
| 69 ExpectDictIntegerValue(model_neutral.num_server_overwrites, *value, | 68 ExpectDictIntegerValue(model_neutral.num_server_overwrites, *value, |
| 70 "numServerOverwrites"); | 69 "numServerOverwrites"); |
| 71 ExpectDictDictionaryValue(*expected_download_progress_markers_value, *value, | 70 ExpectDictDictionaryValue(*expected_download_progress_markers_value, *value, |
| 72 "downloadProgressMarkers"); | 71 "downloadProgressMarkers"); |
| 73 ExpectDictBooleanValue(kIsSilenced, *value, "isSilenced"); | 72 ExpectDictBooleanValue(kIsSilenced, *value, "isSilenced"); |
| 74 ExpectDictIntegerValue(kNumEncryptionConflicts, *value, | 73 ExpectDictIntegerValue(kNumEncryptionConflicts, *value, |
| 75 "numEncryptionConflicts"); | 74 "numEncryptionConflicts"); |
| 76 ExpectDictIntegerValue(kNumHierarchyConflicts, *value, | 75 ExpectDictIntegerValue(kNumHierarchyConflicts, *value, |
| 77 "numHierarchyConflicts"); | 76 "numHierarchyConflicts"); |
| 78 ExpectDictIntegerValue(kNumServerConflicts, *value, "numServerConflicts"); | 77 ExpectDictIntegerValue(kNumServerConflicts, *value, "numServerConflicts"); |
| 79 ExpectDictBooleanValue(false, *value, "notificationsEnabled"); | 78 ExpectDictBooleanValue(false, *value, "notificationsEnabled"); |
| 80 } | 79 } |
| 81 | 80 |
| 82 } // namespace | 81 } // namespace |
| 83 } // namespace sessions | |
| 84 } // namespace syncer | 82 } // namespace syncer |
| OLD | NEW |