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 "sync/internal_api/public/sessions/sync_source_info.h" | 10 #include "sync/internal_api/public/sessions/sync_source_info.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 ModelNeutralState model_neutral; | 26 ModelNeutralState model_neutral; |
27 model_neutral.num_server_changes_remaining = 105; | 27 model_neutral.num_server_changes_remaining = 105; |
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 const bool kIsShareUsable = true; | |
37 | |
38 const ModelTypeSet initial_sync_ended(BOOKMARKS, PREFERENCES); | |
39 scoped_ptr<ListValue> expected_initial_sync_ended_value( | |
40 ModelTypeSetToValue(initial_sync_ended)); | |
41 | |
42 ProgressMarkerMap download_progress_markers; | 36 ProgressMarkerMap download_progress_markers; |
43 download_progress_markers[BOOKMARKS] = "test"; | 37 download_progress_markers[BOOKMARKS] = "test"; |
44 download_progress_markers[APPS] = "apps"; | 38 download_progress_markers[APPS] = "apps"; |
45 scoped_ptr<DictionaryValue> expected_download_progress_markers_value( | 39 scoped_ptr<DictionaryValue> expected_download_progress_markers_value( |
46 ProgressMarkerMapToValue(download_progress_markers)); | 40 ProgressMarkerMapToValue(download_progress_markers)); |
47 | 41 |
48 const bool kIsSilenced = true; | 42 const bool kIsSilenced = true; |
49 const int kNumEncryptionConflicts = 1054; | 43 const int kNumEncryptionConflicts = 1054; |
50 const int kNumHierarchyConflicts = 1055; | 44 const int kNumHierarchyConflicts = 1055; |
51 const int kNumServerConflicts = 1057; | 45 const int kNumServerConflicts = 1057; |
52 | 46 |
53 SyncSourceInfo source; | 47 SyncSourceInfo source; |
54 scoped_ptr<DictionaryValue> expected_source_value(source.ToValue()); | 48 scoped_ptr<DictionaryValue> expected_source_value(source.ToValue()); |
55 | 49 |
56 std::vector<SyncSourceInfo> debug_info_sources_list; | 50 std::vector<SyncSourceInfo> debug_info_sources_list; |
57 debug_info_sources_list.push_back(source); | 51 debug_info_sources_list.push_back(source); |
58 scoped_ptr<ListValue> expected_sources_list_value(new ListValue()); | 52 scoped_ptr<ListValue> expected_sources_list_value(new ListValue()); |
59 expected_sources_list_value->Append(source.ToValue()); | 53 expected_sources_list_value->Append(source.ToValue()); |
60 | 54 |
61 SyncSessionSnapshot snapshot(model_neutral, | 55 SyncSessionSnapshot snapshot(model_neutral, |
62 kIsShareUsable, | |
63 initial_sync_ended, | |
64 download_progress_markers, | 56 download_progress_markers, |
65 kIsSilenced, | 57 kIsSilenced, |
66 kNumEncryptionConflicts, | 58 kNumEncryptionConflicts, |
67 kNumHierarchyConflicts, | 59 kNumHierarchyConflicts, |
68 kNumServerConflicts, | 60 kNumServerConflicts, |
69 source, | 61 source, |
70 debug_info_sources_list, | 62 debug_info_sources_list, |
71 false, | 63 false, |
72 0, | 64 0, |
73 base::Time::Now(), | 65 base::Time::Now(), |
74 std::vector<int>(MODEL_TYPE_COUNT,0), | 66 std::vector<int>(MODEL_TYPE_COUNT,0), |
75 std::vector<int>(MODEL_TYPE_COUNT, 0)); | 67 std::vector<int>(MODEL_TYPE_COUNT, 0)); |
76 scoped_ptr<DictionaryValue> value(snapshot.ToValue()); | 68 scoped_ptr<DictionaryValue> value(snapshot.ToValue()); |
77 EXPECT_EQ(20u, value->size()); | 69 EXPECT_EQ(18u, value->size()); |
78 ExpectDictIntegerValue(model_neutral.num_successful_commits, | 70 ExpectDictIntegerValue(model_neutral.num_successful_commits, |
79 *value, "numSuccessfulCommits"); | 71 *value, "numSuccessfulCommits"); |
80 ExpectDictIntegerValue(model_neutral.num_successful_bookmark_commits, | 72 ExpectDictIntegerValue(model_neutral.num_successful_bookmark_commits, |
81 *value, "numSuccessfulBookmarkCommits"); | 73 *value, "numSuccessfulBookmarkCommits"); |
82 ExpectDictIntegerValue(model_neutral.num_updates_downloaded_total, | 74 ExpectDictIntegerValue(model_neutral.num_updates_downloaded_total, |
83 *value, "numUpdatesDownloadedTotal"); | 75 *value, "numUpdatesDownloadedTotal"); |
84 ExpectDictIntegerValue(model_neutral.num_tombstone_updates_downloaded_total, | 76 ExpectDictIntegerValue(model_neutral.num_tombstone_updates_downloaded_total, |
85 *value, "numTombstoneUpdatesDownloadedTotal"); | 77 *value, "numTombstoneUpdatesDownloadedTotal"); |
86 ExpectDictIntegerValue(model_neutral.num_reflected_updates_downloaded_total, | 78 ExpectDictIntegerValue(model_neutral.num_reflected_updates_downloaded_total, |
87 *value, "numReflectedUpdatesDownloadedTotal"); | 79 *value, "numReflectedUpdatesDownloadedTotal"); |
88 ExpectDictIntegerValue(model_neutral.num_local_overwrites, | 80 ExpectDictIntegerValue(model_neutral.num_local_overwrites, |
89 *value, "numLocalOverwrites"); | 81 *value, "numLocalOverwrites"); |
90 ExpectDictIntegerValue(model_neutral.num_server_overwrites, | 82 ExpectDictIntegerValue(model_neutral.num_server_overwrites, |
91 *value, "numServerOverwrites"); | 83 *value, "numServerOverwrites"); |
92 ExpectDictIntegerValue(model_neutral.num_server_changes_remaining, | 84 ExpectDictIntegerValue(model_neutral.num_server_changes_remaining, |
93 *value, "numServerChangesRemaining"); | 85 *value, "numServerChangesRemaining"); |
94 ExpectDictBooleanValue(kIsShareUsable, *value, "isShareUsable"); | |
95 ExpectDictListValue(*expected_initial_sync_ended_value, *value, | |
96 "initialSyncEnded"); | |
97 ExpectDictDictionaryValue(*expected_download_progress_markers_value, | 86 ExpectDictDictionaryValue(*expected_download_progress_markers_value, |
98 *value, "downloadProgressMarkers"); | 87 *value, "downloadProgressMarkers"); |
99 ExpectDictBooleanValue(kIsSilenced, *value, "isSilenced"); | 88 ExpectDictBooleanValue(kIsSilenced, *value, "isSilenced"); |
100 ExpectDictIntegerValue(kNumEncryptionConflicts, *value, | 89 ExpectDictIntegerValue(kNumEncryptionConflicts, *value, |
101 "numEncryptionConflicts"); | 90 "numEncryptionConflicts"); |
102 ExpectDictIntegerValue(kNumHierarchyConflicts, *value, | 91 ExpectDictIntegerValue(kNumHierarchyConflicts, *value, |
103 "numHierarchyConflicts"); | 92 "numHierarchyConflicts"); |
104 ExpectDictIntegerValue(kNumServerConflicts, *value, | 93 ExpectDictIntegerValue(kNumServerConflicts, *value, |
105 "numServerConflicts"); | 94 "numServerConflicts"); |
106 ExpectDictDictionaryValue(*expected_source_value, *value, "source"); | 95 ExpectDictDictionaryValue(*expected_source_value, *value, "source"); |
107 ExpectDictListValue(*expected_sources_list_value, *value, "sourcesList"); | 96 ExpectDictListValue(*expected_sources_list_value, *value, "sourcesList"); |
108 ExpectDictBooleanValue(false, *value, "notificationsEnabled"); | 97 ExpectDictBooleanValue(false, *value, "notificationsEnabled"); |
109 } | 98 } |
110 | 99 |
111 } // namespace | 100 } // namespace |
112 } // namespace sessions | 101 } // namespace sessions |
113 } // namespace syncer | 102 } // namespace syncer |
OLD | NEW |