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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 void PumpLoop() { | 42 void PumpLoop() { |
43 message_loop_.RunAllPending(); | 43 message_loop_.RunAllPending(); |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 TEST_F(JsSyncManagerObserverTest, NoArgNotifiations) { | 47 TEST_F(JsSyncManagerObserverTest, NoArgNotifiations) { |
48 InSequence dummy; | 48 InSequence dummy; |
49 | 49 |
50 EXPECT_CALL(mock_js_event_handler_, | 50 EXPECT_CALL(mock_js_event_handler_, |
51 HandleJsEvent("onInitializationComplete", | |
52 HasDetails(JsEventDetails()))); | |
53 EXPECT_CALL(mock_js_event_handler_, | |
54 HandleJsEvent("onStopSyncingPermanently", | 51 HandleJsEvent("onStopSyncingPermanently", |
55 HasDetails(JsEventDetails()))); | 52 HasDetails(JsEventDetails()))); |
56 EXPECT_CALL(mock_js_event_handler_, | 53 EXPECT_CALL(mock_js_event_handler_, |
57 HandleJsEvent("onEncryptionComplete", | 54 HandleJsEvent("onEncryptionComplete", |
58 HasDetails(JsEventDetails()))); | 55 HasDetails(JsEventDetails()))); |
59 | 56 |
60 js_sync_manager_observer_.OnInitializationComplete(WeakHandle<JsBackend>(), | |
61 true); | |
62 js_sync_manager_observer_.OnStopSyncingPermanently(); | 57 js_sync_manager_observer_.OnStopSyncingPermanently(); |
63 js_sync_manager_observer_.OnEncryptionComplete(); | 58 js_sync_manager_observer_.OnEncryptionComplete(); |
64 PumpLoop(); | 59 PumpLoop(); |
65 } | 60 } |
66 | 61 |
| 62 TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) { |
| 63 DictionaryValue expected_details; |
| 64 syncer::ModelTypeSet restored_types; |
| 65 restored_types.Put(BOOKMARKS); |
| 66 restored_types.Put(NIGORI); |
| 67 expected_details.Set("restoredTypes", ModelTypeSetToValue(restored_types)); |
| 68 |
| 69 EXPECT_CALL(mock_js_event_handler_, |
| 70 HandleJsEvent("onInitializationComplete", |
| 71 HasDetailsAsDictionary(expected_details))); |
| 72 |
| 73 js_sync_manager_observer_.OnInitializationComplete( |
| 74 WeakHandle<JsBackend>(), true, restored_types); |
| 75 PumpLoop(); |
| 76 } |
| 77 |
67 TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) { | 78 TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) { |
68 ModelTypePayloadMap download_progress_markers; | 79 ModelTypePayloadMap download_progress_markers; |
69 sessions::SyncSessionSnapshot snapshot(sessions::ModelNeutralState(), | 80 sessions::SyncSessionSnapshot snapshot(sessions::ModelNeutralState(), |
70 false, | 81 false, |
71 ModelTypeSet(), | 82 ModelTypeSet(), |
72 download_progress_markers, | 83 download_progress_markers, |
73 false, | 84 false, |
74 true, | 85 true, |
75 8, | 86 8, |
76 5, | 87 5, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 HandleJsEvent("onEncryptedTypesChanged", | 209 HandleJsEvent("onEncryptedTypesChanged", |
199 HasDetailsAsDictionary(expected_details))); | 210 HasDetailsAsDictionary(expected_details))); |
200 | 211 |
201 js_sync_manager_observer_.OnEncryptedTypesChanged( | 212 js_sync_manager_observer_.OnEncryptedTypesChanged( |
202 encrypted_types, encrypt_everything); | 213 encrypted_types, encrypt_everything); |
203 PumpLoop(); | 214 PumpLoop(); |
204 } | 215 } |
205 | 216 |
206 } // namespace | 217 } // namespace |
207 } // namespace syncer | 218 } // namespace syncer |
OLD | NEW |