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