| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 js_sync_manager_observer_.OnInitializationComplete(WeakHandle<JsBackend>(), | 65 js_sync_manager_observer_.OnInitializationComplete(WeakHandle<JsBackend>(), |
| 66 true); | 66 true); |
| 67 js_sync_manager_observer_.OnStopSyncingPermanently(); | 67 js_sync_manager_observer_.OnStopSyncingPermanently(); |
| 68 js_sync_manager_observer_.OnClearServerDataSucceeded(); | 68 js_sync_manager_observer_.OnClearServerDataSucceeded(); |
| 69 js_sync_manager_observer_.OnClearServerDataFailed(); | 69 js_sync_manager_observer_.OnClearServerDataFailed(); |
| 70 js_sync_manager_observer_.OnEncryptionComplete(); | 70 js_sync_manager_observer_.OnEncryptionComplete(); |
| 71 PumpLoop(); | 71 PumpLoop(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) { | 74 TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) { |
| 75 std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; | 75 syncable::ModelTypePayloadMap download_progress_markers; |
| 76 sessions::SyncSessionSnapshot snapshot(sessions::SyncerStatus(), | 76 sessions::SyncSessionSnapshot snapshot(sessions::SyncerStatus(), |
| 77 sessions::ErrorCounters(), | 77 sessions::ErrorCounters(), |
| 78 100, | 78 100, |
| 79 false, | 79 false, |
| 80 syncable::ModelTypeSet(), | 80 syncable::ModelTypeSet(), |
| 81 download_progress_markers, | 81 download_progress_markers, |
| 82 false, | 82 false, |
| 83 true, | 83 true, |
| 84 100, | 84 100, |
| 85 8, | 85 8, |
| 86 5, | 86 5, |
| 87 2, | 87 2, |
| 88 7, | 88 7, |
| 89 false, | 89 false, |
| 90 sessions::SyncSourceInfo(), | 90 sessions::SyncSourceInfo(), |
| 91 false, | 91 false, |
| 92 0, | 92 0, |
| 93 base::Time::Now(), | 93 base::Time::Now(), |
| 94 false); | 94 false); |
| 95 DictionaryValue expected_details; | 95 DictionaryValue expected_details; |
| 96 expected_details.Set("snapshot", snapshot.ToValue()); | 96 expected_details.Set("snapshot", snapshot.ToValue()); |
| 97 | 97 |
| 98 EXPECT_CALL(mock_js_event_handler_, | 98 EXPECT_CALL(mock_js_event_handler_, |
| 99 HandleJsEvent("onSyncCycleCompleted", | 99 HandleJsEvent("onSyncCycleCompleted", |
| 100 HasDetailsAsDictionary(expected_details))); | 100 HasDetailsAsDictionary(expected_details))); |
| 101 | 101 |
| 102 js_sync_manager_observer_.OnSyncCycleCompleted(&snapshot); | 102 js_sync_manager_observer_.OnSyncCycleCompleted(snapshot); |
| 103 PumpLoop(); | 103 PumpLoop(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 TEST_F(JsSyncManagerObserverTest, OnActionableError) { | 106 TEST_F(JsSyncManagerObserverTest, OnActionableError) { |
| 107 browser_sync::SyncProtocolError sync_error; | 107 browser_sync::SyncProtocolError sync_error; |
| 108 sync_error.action = browser_sync::CLEAR_USER_DATA_AND_RESYNC; | 108 sync_error.action = browser_sync::CLEAR_USER_DATA_AND_RESYNC; |
| 109 sync_error.error_type = browser_sync::TRANSIENT_ERROR; | 109 sync_error.error_type = browser_sync::TRANSIENT_ERROR; |
| 110 DictionaryValue expected_details; | 110 DictionaryValue expected_details; |
| 111 expected_details.Set("syncError", sync_error.ToValue()); | 111 expected_details.Set("syncError", sync_error.ToValue()); |
| 112 | 112 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 HandleJsEvent("onEncryptedTypesChanged", | 212 HandleJsEvent("onEncryptedTypesChanged", |
| 213 HasDetailsAsDictionary(expected_details))); | 213 HasDetailsAsDictionary(expected_details))); |
| 214 | 214 |
| 215 js_sync_manager_observer_.OnEncryptedTypesChanged( | 215 js_sync_manager_observer_.OnEncryptedTypesChanged( |
| 216 encrypted_types, encrypt_everything); | 216 encrypted_types, encrypt_everything); |
| 217 PumpLoop(); | 217 PumpLoop(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace | 220 } // namespace |
| 221 } // namespace browser_sync | 221 } // namespace browser_sync |
| OLD | NEW |