| 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/internal_api/public/sessions/sync_session_snapshot.h" | 5 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/test/values_test_util.h" | 8 #include "base/test/values_test_util.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace syncer { | 12 namespace syncer { |
| 13 namespace sessions { | 13 namespace sessions { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 using base::ExpectDictBooleanValue; | 16 using base::ExpectDictBooleanValue; |
| 17 using base::ExpectDictDictionaryValue; | 17 using base::ExpectDictDictionaryValue; |
| 18 using base::ExpectDictIntegerValue; | 18 using base::ExpectDictIntegerValue; |
| 19 using base::ExpectDictListValue; | 19 using base::ExpectDictListValue; |
| 20 using base::ExpectDictStringValue; | 20 using base::ExpectDictStringValue; |
| 21 | 21 |
| 22 class SyncSessionSnapshotTest : public testing::Test {}; | 22 class SyncSessionSnapshotTest : public testing::Test {}; |
| 23 | 23 |
| 24 TEST_F(SyncSessionSnapshotTest, SyncSessionSnapshotToValue) { | 24 TEST_F(SyncSessionSnapshotTest, SyncSessionSnapshotToValue) { |
| 25 ModelNeutralState model_neutral; | 25 ModelNeutralState model_neutral; |
| 26 model_neutral.num_server_changes_remaining = 105; | |
| 27 model_neutral.num_successful_commits = 5; | 26 model_neutral.num_successful_commits = 5; |
| 28 model_neutral.num_successful_bookmark_commits = 10; | 27 model_neutral.num_successful_bookmark_commits = 10; |
| 29 model_neutral.num_updates_downloaded_total = 100; | 28 model_neutral.num_updates_downloaded_total = 100; |
| 30 model_neutral.num_tombstone_updates_downloaded_total = 200; | 29 model_neutral.num_tombstone_updates_downloaded_total = 200; |
| 31 model_neutral.num_reflected_updates_downloaded_total = 50; | 30 model_neutral.num_reflected_updates_downloaded_total = 50; |
| 32 model_neutral.num_local_overwrites = 15; | 31 model_neutral.num_local_overwrites = 15; |
| 33 model_neutral.num_server_overwrites = 18; | 32 model_neutral.num_server_overwrites = 18; |
| 34 | 33 |
| 35 ProgressMarkerMap download_progress_markers; | 34 ProgressMarkerMap download_progress_markers; |
| 36 download_progress_markers[BOOKMARKS] = "test"; | 35 download_progress_markers[BOOKMARKS] = "test"; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 49 kNumEncryptionConflicts, | 48 kNumEncryptionConflicts, |
| 50 kNumHierarchyConflicts, | 49 kNumHierarchyConflicts, |
| 51 kNumServerConflicts, | 50 kNumServerConflicts, |
| 52 false, | 51 false, |
| 53 0, | 52 0, |
| 54 base::Time::Now(), | 53 base::Time::Now(), |
| 55 std::vector<int>(MODEL_TYPE_COUNT,0), | 54 std::vector<int>(MODEL_TYPE_COUNT,0), |
| 56 std::vector<int>(MODEL_TYPE_COUNT, 0), | 55 std::vector<int>(MODEL_TYPE_COUNT, 0), |
| 57 sync_pb::GetUpdatesCallerInfo::UNKNOWN); | 56 sync_pb::GetUpdatesCallerInfo::UNKNOWN); |
| 58 scoped_ptr<base::DictionaryValue> value(snapshot.ToValue()); | 57 scoped_ptr<base::DictionaryValue> value(snapshot.ToValue()); |
| 59 EXPECT_EQ(17u, value->size()); | 58 EXPECT_EQ(16u, value->size()); |
| 60 ExpectDictIntegerValue(model_neutral.num_successful_commits, | 59 ExpectDictIntegerValue(model_neutral.num_successful_commits, |
| 61 *value, "numSuccessfulCommits"); | 60 *value, "numSuccessfulCommits"); |
| 62 ExpectDictIntegerValue(model_neutral.num_successful_bookmark_commits, | 61 ExpectDictIntegerValue(model_neutral.num_successful_bookmark_commits, |
| 63 *value, "numSuccessfulBookmarkCommits"); | 62 *value, "numSuccessfulBookmarkCommits"); |
| 64 ExpectDictIntegerValue(model_neutral.num_updates_downloaded_total, | 63 ExpectDictIntegerValue(model_neutral.num_updates_downloaded_total, |
| 65 *value, "numUpdatesDownloadedTotal"); | 64 *value, "numUpdatesDownloadedTotal"); |
| 66 ExpectDictIntegerValue(model_neutral.num_tombstone_updates_downloaded_total, | 65 ExpectDictIntegerValue(model_neutral.num_tombstone_updates_downloaded_total, |
| 67 *value, "numTombstoneUpdatesDownloadedTotal"); | 66 *value, "numTombstoneUpdatesDownloadedTotal"); |
| 68 ExpectDictIntegerValue(model_neutral.num_reflected_updates_downloaded_total, | 67 ExpectDictIntegerValue(model_neutral.num_reflected_updates_downloaded_total, |
| 69 *value, "numReflectedUpdatesDownloadedTotal"); | 68 *value, "numReflectedUpdatesDownloadedTotal"); |
| 70 ExpectDictIntegerValue(model_neutral.num_local_overwrites, | 69 ExpectDictIntegerValue(model_neutral.num_local_overwrites, |
| 71 *value, "numLocalOverwrites"); | 70 *value, "numLocalOverwrites"); |
| 72 ExpectDictIntegerValue(model_neutral.num_server_overwrites, | 71 ExpectDictIntegerValue(model_neutral.num_server_overwrites, |
| 73 *value, "numServerOverwrites"); | 72 *value, "numServerOverwrites"); |
| 74 ExpectDictIntegerValue(model_neutral.num_server_changes_remaining, | |
| 75 *value, "numServerChangesRemaining"); | |
| 76 ExpectDictDictionaryValue(*expected_download_progress_markers_value, | 73 ExpectDictDictionaryValue(*expected_download_progress_markers_value, |
| 77 *value, "downloadProgressMarkers"); | 74 *value, "downloadProgressMarkers"); |
| 78 ExpectDictBooleanValue(kIsSilenced, *value, "isSilenced"); | 75 ExpectDictBooleanValue(kIsSilenced, *value, "isSilenced"); |
| 79 ExpectDictIntegerValue(kNumEncryptionConflicts, *value, | 76 ExpectDictIntegerValue(kNumEncryptionConflicts, *value, |
| 80 "numEncryptionConflicts"); | 77 "numEncryptionConflicts"); |
| 81 ExpectDictIntegerValue(kNumHierarchyConflicts, *value, | 78 ExpectDictIntegerValue(kNumHierarchyConflicts, *value, |
| 82 "numHierarchyConflicts"); | 79 "numHierarchyConflicts"); |
| 83 ExpectDictIntegerValue(kNumServerConflicts, *value, | 80 ExpectDictIntegerValue(kNumServerConflicts, *value, |
| 84 "numServerConflicts"); | 81 "numServerConflicts"); |
| 85 ExpectDictBooleanValue(false, *value, "notificationsEnabled"); | 82 ExpectDictBooleanValue(false, *value, "notificationsEnabled"); |
| 86 } | 83 } |
| 87 | 84 |
| 88 } // namespace | 85 } // namespace |
| 89 } // namespace sessions | 86 } // namespace sessions |
| 90 } // namespace syncer | 87 } // namespace syncer |
| OLD | NEW |