Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: sync/sessions/session_state_unittest.cc

Issue 11314008: sync: Follow-up to conflict resolution refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/sessions/session_state.cc ('k') | sync/sessions/status_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/sessions/session_state.h"
6
7 #include <string>
8
9 #include "base/base64.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/test/values_test_util.h"
12 #include "base/time.h"
13 #include "base/values.h"
14 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
15 #include "sync/internal_api/public/sessions/sync_source_info.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace syncer {
19 namespace sessions {
20 namespace {
21
22 using base::ExpectDictBooleanValue;
23 using base::ExpectDictDictionaryValue;
24 using base::ExpectDictIntegerValue;
25 using base::ExpectDictListValue;
26 using base::ExpectDictStringValue;
27
28 class SessionStateTest : public testing::Test {};
29
30 TEST_F(SessionStateTest, SyncSourceInfoToValue) {
31 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source =
32 sync_pb::GetUpdatesCallerInfo::PERIODIC;
33 ModelTypeInvalidationMap types;
34 types[PREFERENCES].payload = "preferencespayload";
35 types[EXTENSIONS].payload = "";
36 scoped_ptr<DictionaryValue> expected_types_value(
37 ModelTypeInvalidationMapToValue(types));
38
39 SyncSourceInfo source_info(updates_source, types);
40
41 scoped_ptr<DictionaryValue> value(source_info.ToValue());
42 EXPECT_EQ(2u, value->size());
43 ExpectDictStringValue("PERIODIC", *value, "updatesSource");
44 ExpectDictDictionaryValue(*expected_types_value, *value, "types");
45 }
46
47 TEST_F(SessionStateTest, SyncSessionSnapshotToValue) {
48 ModelNeutralState model_neutral;
49 model_neutral.num_server_changes_remaining = 105;
50 model_neutral.num_successful_commits = 5;
51 model_neutral.num_successful_bookmark_commits = 10;
52 model_neutral.num_updates_downloaded_total = 100;
53 model_neutral.num_tombstone_updates_downloaded_total = 200;
54 model_neutral.num_reflected_updates_downloaded_total = 50;
55 model_neutral.num_local_overwrites = 15;
56 model_neutral.num_server_overwrites = 18;
57
58 const bool kIsShareUsable = true;
59
60 const ModelTypeSet initial_sync_ended(BOOKMARKS, PREFERENCES);
61 scoped_ptr<ListValue> expected_initial_sync_ended_value(
62 ModelTypeSetToValue(initial_sync_ended));
63
64 ProgressMarkerMap download_progress_markers;
65 download_progress_markers[BOOKMARKS] = "test";
66 download_progress_markers[APPS] = "apps";
67 scoped_ptr<DictionaryValue> expected_download_progress_markers_value(
68 ProgressMarkerMapToValue(download_progress_markers));
69
70 const bool kHasMoreToSync = false;
71 const bool kIsSilenced = true;
72 const int kNumEncryptionConflicts = 1054;
73 const int kNumHierarchyConflicts = 1055;
74 const int kNumSimpleConflicts = 1056;
75 const int kNumServerConflicts = 1057;
76
77 SyncSourceInfo source;
78 scoped_ptr<DictionaryValue> expected_source_value(source.ToValue());
79
80 SyncSessionSnapshot snapshot(model_neutral,
81 kIsShareUsable,
82 initial_sync_ended,
83 download_progress_markers,
84 kHasMoreToSync,
85 kIsSilenced,
86 kNumEncryptionConflicts,
87 kNumHierarchyConflicts,
88 kNumSimpleConflicts,
89 kNumServerConflicts,
90 source,
91 false,
92 0,
93 base::Time::Now());
94 scoped_ptr<DictionaryValue> value(snapshot.ToValue());
95 EXPECT_EQ(20u, value->size());
96 ExpectDictIntegerValue(model_neutral.num_successful_commits,
97 *value, "numSuccessfulCommits");
98 ExpectDictIntegerValue(model_neutral.num_successful_bookmark_commits,
99 *value, "numSuccessfulBookmarkCommits");
100 ExpectDictIntegerValue(model_neutral.num_updates_downloaded_total,
101 *value, "numUpdatesDownloadedTotal");
102 ExpectDictIntegerValue(model_neutral.num_tombstone_updates_downloaded_total,
103 *value, "numTombstoneUpdatesDownloadedTotal");
104 ExpectDictIntegerValue(model_neutral.num_reflected_updates_downloaded_total,
105 *value, "numReflectedUpdatesDownloadedTotal");
106 ExpectDictIntegerValue(model_neutral.num_local_overwrites,
107 *value, "numLocalOverwrites");
108 ExpectDictIntegerValue(model_neutral.num_server_overwrites,
109 *value, "numServerOverwrites");
110 ExpectDictIntegerValue(model_neutral.num_server_changes_remaining,
111 *value, "numServerChangesRemaining");
112 ExpectDictBooleanValue(kIsShareUsable, *value, "isShareUsable");
113 ExpectDictListValue(*expected_initial_sync_ended_value, *value,
114 "initialSyncEnded");
115 ExpectDictDictionaryValue(*expected_download_progress_markers_value,
116 *value, "downloadProgressMarkers");
117 ExpectDictBooleanValue(kHasMoreToSync, *value, "hasMoreToSync");
118 ExpectDictBooleanValue(kIsSilenced, *value, "isSilenced");
119 ExpectDictIntegerValue(kNumEncryptionConflicts, *value,
120 "numEncryptionConflicts");
121 ExpectDictIntegerValue(kNumHierarchyConflicts, *value,
122 "numHierarchyConflicts");
123 ExpectDictIntegerValue(kNumSimpleConflicts, *value,
124 "numSimpleConflicts");
125 ExpectDictIntegerValue(kNumServerConflicts, *value,
126 "numServerConflicts");
127 ExpectDictDictionaryValue(*expected_source_value, *value, "source");
128 ExpectDictBooleanValue(false, *value, "notificationsEnabled");
129 }
130
131 } // namespace
132 } // namespace sessions
133 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/sessions/session_state.cc ('k') | sync/sessions/status_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698