| 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/js_sync_manager_observer.h" | 5 #include "sync/internal_api/js_sync_manager_observer.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 HasDetails(JsEventDetails()))); | 57 HasDetails(JsEventDetails()))); |
| 58 | 58 |
| 59 js_sync_manager_observer_.OnInitializationComplete(WeakHandle<JsBackend>(), | 59 js_sync_manager_observer_.OnInitializationComplete(WeakHandle<JsBackend>(), |
| 60 true); | 60 true); |
| 61 js_sync_manager_observer_.OnStopSyncingPermanently(); | 61 js_sync_manager_observer_.OnStopSyncingPermanently(); |
| 62 js_sync_manager_observer_.OnEncryptionComplete(); | 62 js_sync_manager_observer_.OnEncryptionComplete(); |
| 63 PumpLoop(); | 63 PumpLoop(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) { | 66 TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) { |
| 67 syncable::ModelTypePayloadMap download_progress_markers; | 67 syncer::ModelTypePayloadMap download_progress_markers; |
| 68 sessions::SyncSessionSnapshot snapshot(sessions::ModelNeutralState(), | 68 sessions::SyncSessionSnapshot snapshot(sessions::ModelNeutralState(), |
| 69 false, | 69 false, |
| 70 syncable::ModelTypeSet(), | 70 syncer::ModelTypeSet(), |
| 71 download_progress_markers, | 71 download_progress_markers, |
| 72 false, | 72 false, |
| 73 true, | 73 true, |
| 74 8, | 74 8, |
| 75 5, | 75 5, |
| 76 2, | 76 2, |
| 77 7, | 77 7, |
| 78 sessions::SyncSourceInfo(), | 78 sessions::SyncSourceInfo(), |
| 79 false, | 79 false, |
| 80 0, | 80 0, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 js_sync_manager_observer_.OnBootstrapTokenUpdated("sensitive_token"); | 179 js_sync_manager_observer_.OnBootstrapTokenUpdated("sensitive_token"); |
| 180 PumpLoop(); | 180 PumpLoop(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 TEST_F(JsSyncManagerObserverTest, OnEncryptedTypesChanged) { | 183 TEST_F(JsSyncManagerObserverTest, OnEncryptedTypesChanged) { |
| 184 DictionaryValue expected_details; | 184 DictionaryValue expected_details; |
| 185 ListValue* encrypted_type_values = new ListValue(); | 185 ListValue* encrypted_type_values = new ListValue(); |
| 186 const bool encrypt_everything = false; | 186 const bool encrypt_everything = false; |
| 187 expected_details.Set("encryptedTypes", encrypted_type_values); | 187 expected_details.Set("encryptedTypes", encrypted_type_values); |
| 188 expected_details.SetBoolean("encryptEverything", encrypt_everything); | 188 expected_details.SetBoolean("encryptEverything", encrypt_everything); |
| 189 syncable::ModelTypeSet encrypted_types; | 189 syncer::ModelTypeSet encrypted_types; |
| 190 | 190 |
| 191 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | 191 for (int i = syncer::FIRST_REAL_MODEL_TYPE; |
| 192 i < syncable::MODEL_TYPE_COUNT; ++i) { | 192 i < syncer::MODEL_TYPE_COUNT; ++i) { |
| 193 syncable::ModelType type = syncable::ModelTypeFromInt(i); | 193 syncer::ModelType type = syncer::ModelTypeFromInt(i); |
| 194 encrypted_types.Put(type); | 194 encrypted_types.Put(type); |
| 195 encrypted_type_values->Append(Value::CreateStringValue( | 195 encrypted_type_values->Append(Value::CreateStringValue( |
| 196 syncable::ModelTypeToString(type))); | 196 syncer::ModelTypeToString(type))); |
| 197 } | 197 } |
| 198 | 198 |
| 199 EXPECT_CALL(mock_js_event_handler_, | 199 EXPECT_CALL(mock_js_event_handler_, |
| 200 HandleJsEvent("onEncryptedTypesChanged", | 200 HandleJsEvent("onEncryptedTypesChanged", |
| 201 HasDetailsAsDictionary(expected_details))); | 201 HasDetailsAsDictionary(expected_details))); |
| 202 | 202 |
| 203 js_sync_manager_observer_.OnEncryptedTypesChanged( | 203 js_sync_manager_observer_.OnEncryptedTypesChanged( |
| 204 encrypted_types, encrypt_everything); | 204 encrypted_types, encrypt_everything); |
| 205 PumpLoop(); | 205 PumpLoop(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace | 208 } // namespace |
| 209 } // namespace syncer | 209 } // namespace syncer |
| OLD | NEW |