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