| 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/sessions/session_state.h" | 5 #include "sync/sessions/session_state.h" | 
| 6 | 6 | 
| 7 #include <string> | 7 #include <string> | 
| 8 | 8 | 
| 9 #include "base/base64.h" | 9 #include "base/base64.h" | 
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 23 using base::ExpectDictDictionaryValue; | 23 using base::ExpectDictDictionaryValue; | 
| 24 using base::ExpectDictIntegerValue; | 24 using base::ExpectDictIntegerValue; | 
| 25 using base::ExpectDictListValue; | 25 using base::ExpectDictListValue; | 
| 26 using base::ExpectDictStringValue; | 26 using base::ExpectDictStringValue; | 
| 27 | 27 | 
| 28 class SessionStateTest : public testing::Test {}; | 28 class SessionStateTest : public testing::Test {}; | 
| 29 | 29 | 
| 30 TEST_F(SessionStateTest, SyncSourceInfoToValue) { | 30 TEST_F(SessionStateTest, SyncSourceInfoToValue) { | 
| 31   sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source = | 31   sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source = | 
| 32       sync_pb::GetUpdatesCallerInfo::PERIODIC; | 32       sync_pb::GetUpdatesCallerInfo::PERIODIC; | 
| 33   ModelTypePayloadMap types; | 33   ModelTypeStateMap types; | 
| 34   types[PREFERENCES] = "preferencespayload"; | 34   types[PREFERENCES].payload = "preferencespayload"; | 
| 35   types[EXTENSIONS] = ""; | 35   types[EXTENSIONS].payload = ""; | 
| 36   scoped_ptr<DictionaryValue> expected_types_value( | 36   scoped_ptr<DictionaryValue> expected_types_value( | 
| 37       ModelTypePayloadMapToValue(types)); | 37       ModelTypeStateMapToValue(types)); | 
| 38 | 38 | 
| 39   SyncSourceInfo source_info(updates_source, types); | 39   SyncSourceInfo source_info(updates_source, types); | 
| 40 | 40 | 
| 41   scoped_ptr<DictionaryValue> value(source_info.ToValue()); | 41   scoped_ptr<DictionaryValue> value(source_info.ToValue()); | 
| 42   EXPECT_EQ(2u, value->size()); | 42   EXPECT_EQ(2u, value->size()); | 
| 43   ExpectDictStringValue("PERIODIC", *value, "updatesSource"); | 43   ExpectDictStringValue("PERIODIC", *value, "updatesSource"); | 
| 44   ExpectDictDictionaryValue(*expected_types_value, *value, "types"); | 44   ExpectDictDictionaryValue(*expected_types_value, *value, "types"); | 
| 45 } | 45 } | 
| 46 | 46 | 
| 47 TEST_F(SessionStateTest, SyncSessionSnapshotToValue) { | 47 TEST_F(SessionStateTest, SyncSessionSnapshotToValue) { | 
| 48   ModelNeutralState model_neutral; | 48   ModelNeutralState model_neutral; | 
| 49   model_neutral.num_server_changes_remaining = 105; | 49   model_neutral.num_server_changes_remaining = 105; | 
| 50   model_neutral.num_successful_commits = 5; | 50   model_neutral.num_successful_commits = 5; | 
| 51   model_neutral.num_successful_bookmark_commits = 10; | 51   model_neutral.num_successful_bookmark_commits = 10; | 
| 52   model_neutral.num_updates_downloaded_total = 100; | 52   model_neutral.num_updates_downloaded_total = 100; | 
| 53   model_neutral.num_tombstone_updates_downloaded_total = 200; | 53   model_neutral.num_tombstone_updates_downloaded_total = 200; | 
| 54   model_neutral.num_reflected_updates_downloaded_total = 50; | 54   model_neutral.num_reflected_updates_downloaded_total = 50; | 
| 55   model_neutral.num_local_overwrites = 15; | 55   model_neutral.num_local_overwrites = 15; | 
| 56   model_neutral.num_server_overwrites = 18; | 56   model_neutral.num_server_overwrites = 18; | 
| 57 | 57 | 
| 58   const bool kIsShareUsable = true; | 58   const bool kIsShareUsable = true; | 
| 59 | 59 | 
| 60   const ModelTypeSet initial_sync_ended(BOOKMARKS, PREFERENCES); | 60   const ModelTypeSet initial_sync_ended(BOOKMARKS, PREFERENCES); | 
| 61   scoped_ptr<ListValue> expected_initial_sync_ended_value( | 61   scoped_ptr<ListValue> expected_initial_sync_ended_value( | 
| 62       ModelTypeSetToValue(initial_sync_ended)); | 62       ModelTypeSetToValue(initial_sync_ended)); | 
| 63 | 63 | 
| 64   ModelTypePayloadMap download_progress_markers; | 64   ModelTypeStateMap download_progress_markers; | 
| 65   download_progress_markers[BOOKMARKS] = "test"; | 65   download_progress_markers[BOOKMARKS].payload = "test"; | 
| 66   download_progress_markers[APPS] = "apps"; | 66   download_progress_markers[APPS].payload = "apps"; | 
| 67   scoped_ptr<DictionaryValue> expected_download_progress_markers_value( | 67   scoped_ptr<DictionaryValue> expected_download_progress_markers_value( | 
| 68       ModelTypePayloadMapToValue(download_progress_markers)); | 68       ModelTypeStateMapToValue(download_progress_markers)); | 
| 69 | 69 | 
| 70   const bool kHasMoreToSync = false; | 70   const bool kHasMoreToSync = false; | 
| 71   const bool kIsSilenced = true; | 71   const bool kIsSilenced = true; | 
| 72   const int kNumEncryptionConflicts = 1054; | 72   const int kNumEncryptionConflicts = 1054; | 
| 73   const int kNumHierarchyConflicts = 1055; | 73   const int kNumHierarchyConflicts = 1055; | 
| 74   const int kNumSimpleConflicts = 1056; | 74   const int kNumSimpleConflicts = 1056; | 
| 75   const int kNumServerConflicts = 1057; | 75   const int kNumServerConflicts = 1057; | 
| 76 | 76 | 
| 77   SyncSourceInfo source; | 77   SyncSourceInfo source; | 
| 78   scoped_ptr<DictionaryValue> expected_source_value(source.ToValue()); | 78   scoped_ptr<DictionaryValue> expected_source_value(source.ToValue()); | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 125                          "numSimpleConflicts"); | 125                          "numSimpleConflicts"); | 
| 126   ExpectDictIntegerValue(kNumServerConflicts, *value, | 126   ExpectDictIntegerValue(kNumServerConflicts, *value, | 
| 127                          "numServerConflicts"); | 127                          "numServerConflicts"); | 
| 128   ExpectDictDictionaryValue(*expected_source_value, *value, "source"); | 128   ExpectDictDictionaryValue(*expected_source_value, *value, "source"); | 
| 129   ExpectDictBooleanValue(false, *value, "notificationsEnabled"); | 129   ExpectDictBooleanValue(false, *value, "notificationsEnabled"); | 
| 130 } | 130 } | 
| 131 | 131 | 
| 132 }  // namespace | 132 }  // namespace | 
| 133 }  // namespace sessions | 133 }  // namespace sessions | 
| 134 }  // namespace syncer | 134 }  // namespace syncer | 
| OLD | NEW | 
|---|