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