| 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/sessions/session_state.h" | 5 #include "sync/sessions/session_state.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 ExpectDictIntegerValue(status.num_tombstone_updates_downloaded_total, | 65 ExpectDictIntegerValue(status.num_tombstone_updates_downloaded_total, |
| 66 *value, "numTombstoneUpdatesDownloadedTotal"); | 66 *value, "numTombstoneUpdatesDownloadedTotal"); |
| 67 ExpectDictIntegerValue(status.num_reflected_updates_downloaded_total, | 67 ExpectDictIntegerValue(status.num_reflected_updates_downloaded_total, |
| 68 *value, "numReflectedUpdatesDownloadedTotal"); | 68 *value, "numReflectedUpdatesDownloadedTotal"); |
| 69 ExpectDictIntegerValue(status.num_local_overwrites, | 69 ExpectDictIntegerValue(status.num_local_overwrites, |
| 70 *value, "numLocalOverwrites"); | 70 *value, "numLocalOverwrites"); |
| 71 ExpectDictIntegerValue(status.num_server_overwrites, | 71 ExpectDictIntegerValue(status.num_server_overwrites, |
| 72 *value, "numServerOverwrites"); | 72 *value, "numServerOverwrites"); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(SessionStateTest, DownloadProgressMarkersToValue) { | |
| 76 std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; | |
| 77 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | |
| 78 i < syncable::MODEL_TYPE_COUNT; ++i) { | |
| 79 std::string marker(i, i); | |
| 80 download_progress_markers[i] = marker; | |
| 81 } | |
| 82 | |
| 83 scoped_ptr<DictionaryValue> value( | |
| 84 DownloadProgressMarkersToValue(download_progress_markers)); | |
| 85 EXPECT_EQ(syncable::MODEL_TYPE_COUNT - syncable::FIRST_REAL_MODEL_TYPE, | |
| 86 static_cast<int>(value->size())); | |
| 87 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | |
| 88 i < syncable::MODEL_TYPE_COUNT; ++i) { | |
| 89 syncable::ModelType model_type = syncable::ModelTypeFromInt(i); | |
| 90 std::string marker(i, i); | |
| 91 std::string expected_value; | |
| 92 EXPECT_TRUE(base::Base64Encode(marker, &expected_value)); | |
| 93 ExpectDictStringValue(expected_value, | |
| 94 *value, syncable::ModelTypeToString(model_type)); | |
| 95 } | |
| 96 } | |
| 97 | |
| 98 TEST_F(SessionStateTest, SyncSessionSnapshotToValue) { | 75 TEST_F(SessionStateTest, SyncSessionSnapshotToValue) { |
| 99 SyncerStatus syncer_status; | 76 SyncerStatus syncer_status; |
| 100 syncer_status.num_successful_commits = 500; | 77 syncer_status.num_successful_commits = 500; |
| 101 scoped_ptr<DictionaryValue> expected_syncer_status_value( | 78 scoped_ptr<DictionaryValue> expected_syncer_status_value( |
| 102 syncer_status.ToValue()); | 79 syncer_status.ToValue()); |
| 103 | 80 |
| 104 ErrorCounters errors; | 81 ErrorCounters errors; |
| 105 | 82 |
| 106 const int kNumServerChangesRemaining = 105; | 83 const int kNumServerChangesRemaining = 105; |
| 107 const bool kIsShareUsable = true; | 84 const bool kIsShareUsable = true; |
| 108 | 85 |
| 109 const syncable::ModelTypeSet initial_sync_ended( | 86 const syncable::ModelTypeSet initial_sync_ended( |
| 110 syncable::BOOKMARKS, syncable::PREFERENCES); | 87 syncable::BOOKMARKS, syncable::PREFERENCES); |
| 111 scoped_ptr<ListValue> expected_initial_sync_ended_value( | 88 scoped_ptr<ListValue> expected_initial_sync_ended_value( |
| 112 syncable::ModelTypeSetToValue(initial_sync_ended)); | 89 syncable::ModelTypeSetToValue(initial_sync_ended)); |
| 113 | 90 |
| 114 std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; | 91 syncable::ModelTypePayloadMap download_progress_markers; |
| 115 download_progress_markers[syncable::BOOKMARKS] = "test"; | 92 download_progress_markers[syncable::BOOKMARKS] = "test"; |
| 116 download_progress_markers[syncable::APPS] = "apps"; | 93 download_progress_markers[syncable::APPS] = "apps"; |
| 117 scoped_ptr<DictionaryValue> expected_download_progress_markers_value( | 94 scoped_ptr<DictionaryValue> expected_download_progress_markers_value( |
| 118 DownloadProgressMarkersToValue(download_progress_markers)); | 95 syncable::ModelTypePayloadMapToValue(download_progress_markers)); |
| 119 | 96 |
| 120 const bool kHasMoreToSync = false; | 97 const bool kHasMoreToSync = false; |
| 121 const bool kIsSilenced = true; | 98 const bool kIsSilenced = true; |
| 122 const int kUnsyncedCount = 1053; | 99 const int kUnsyncedCount = 1053; |
| 123 const int kNumEncryptionConflicts = 1054; | 100 const int kNumEncryptionConflicts = 1054; |
| 124 const int kNumHierarchyConflicts = 1055; | 101 const int kNumHierarchyConflicts = 1055; |
| 125 const int kNumSimpleConflicts = 1056; | 102 const int kNumSimpleConflicts = 1056; |
| 126 const int kNumServerConflicts = 1057; | 103 const int kNumServerConflicts = 1057; |
| 127 const bool kDidCommitItems = true; | 104 const bool kDidCommitItems = true; |
| 128 | 105 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 "numServerConflicts"); | 149 "numServerConflicts"); |
| 173 ExpectDictBooleanValue(kDidCommitItems, *value, | 150 ExpectDictBooleanValue(kDidCommitItems, *value, |
| 174 "didCommitItems"); | 151 "didCommitItems"); |
| 175 ExpectDictDictionaryValue(*expected_source_value, *value, "source"); | 152 ExpectDictDictionaryValue(*expected_source_value, *value, "source"); |
| 176 ExpectDictBooleanValue(false, *value, "notificationsEnabled"); | 153 ExpectDictBooleanValue(false, *value, "notificationsEnabled"); |
| 177 } | 154 } |
| 178 | 155 |
| 179 } // namespace | 156 } // namespace |
| 180 } // namespace sessions | 157 } // namespace sessions |
| 181 } // namespace browser_sync | 158 } // namespace browser_sync |
| OLD | NEW |