Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1170)

Side by Side Diff: sync/internal_api/js_sync_manager_observer_unittest.cc

Issue 10520010: Not for review: Support sync init with missing or corrupt store (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Documentation Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 29 matching lines...) Expand all
40 40
41 void PumpLoop() { 41 void PumpLoop() {
42 message_loop_.RunAllPending(); 42 message_loop_.RunAllPending();
43 } 43 }
44 }; 44 };
45 45
46 TEST_F(JsSyncManagerObserverTest, NoArgNotifiations) { 46 TEST_F(JsSyncManagerObserverTest, NoArgNotifiations) {
47 InSequence dummy; 47 InSequence dummy;
48 48
49 EXPECT_CALL(mock_js_event_handler_, 49 EXPECT_CALL(mock_js_event_handler_,
50 HandleJsEvent("onInitializationComplete",
51 HasDetails(JsEventDetails())));
52 EXPECT_CALL(mock_js_event_handler_,
53 HandleJsEvent("onStopSyncingPermanently", 50 HandleJsEvent("onStopSyncingPermanently",
54 HasDetails(JsEventDetails()))); 51 HasDetails(JsEventDetails())));
55 EXPECT_CALL(mock_js_event_handler_, 52 EXPECT_CALL(mock_js_event_handler_,
56 HandleJsEvent("onClearServerDataSucceeded", 53 HandleJsEvent("onClearServerDataSucceeded",
57 HasDetails(JsEventDetails()))); 54 HasDetails(JsEventDetails())));
58 EXPECT_CALL(mock_js_event_handler_, 55 EXPECT_CALL(mock_js_event_handler_,
59 HandleJsEvent("onClearServerDataFailed", 56 HandleJsEvent("onClearServerDataFailed",
60 HasDetails(JsEventDetails()))); 57 HasDetails(JsEventDetails())));
61 EXPECT_CALL(mock_js_event_handler_, 58 EXPECT_CALL(mock_js_event_handler_,
62 HandleJsEvent("onEncryptionComplete", 59 HandleJsEvent("onEncryptionComplete",
63 HasDetails(JsEventDetails()))); 60 HasDetails(JsEventDetails())));
64 61
65 js_sync_manager_observer_.OnInitializationComplete(WeakHandle<JsBackend>(),
66 true);
67 js_sync_manager_observer_.OnStopSyncingPermanently(); 62 js_sync_manager_observer_.OnStopSyncingPermanently();
68 js_sync_manager_observer_.OnClearServerDataSucceeded(); 63 js_sync_manager_observer_.OnClearServerDataSucceeded();
69 js_sync_manager_observer_.OnClearServerDataFailed(); 64 js_sync_manager_observer_.OnClearServerDataFailed();
70 js_sync_manager_observer_.OnEncryptionComplete(); 65 js_sync_manager_observer_.OnEncryptionComplete();
71 PumpLoop(); 66 PumpLoop();
72 } 67 }
73 68
69 TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) {
70 DictionaryValue expected_details;
71 syncable::ModelTypeSet restored_types;
72 restored_types.Put(syncable::BOOKMARKS);
73 restored_types.Put(syncable::NIGORI);
74 expected_details.Set("restoredTypes", ModelTypeSetToValue(restored_types));
75
76 EXPECT_CALL(mock_js_event_handler_,
77 HandleJsEvent("onInitializationComplete",
78 HasDetailsAsDictionary(expected_details)));
79
80 js_sync_manager_observer_.OnInitializationComplete(
81 WeakHandle<JsBackend>(), true, restored_types);
82 PumpLoop();
83 }
84
74 TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) { 85 TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) {
75 syncable::ModelTypePayloadMap download_progress_markers; 86 syncable::ModelTypePayloadMap download_progress_markers;
76 sessions::SyncSessionSnapshot snapshot(sessions::SyncerStatus(), 87 sessions::SyncSessionSnapshot snapshot(sessions::SyncerStatus(),
77 sessions::ErrorCounters(), 88 sessions::ErrorCounters(),
78 100, 89 100,
79 false, 90 false,
80 syncable::ModelTypeSet(), 91 syncable::ModelTypeSet(),
81 download_progress_markers, 92 download_progress_markers,
82 false, 93 false,
83 true, 94 true,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 HandleJsEvent("onEncryptedTypesChanged", 221 HandleJsEvent("onEncryptedTypesChanged",
211 HasDetailsAsDictionary(expected_details))); 222 HasDetailsAsDictionary(expected_details)));
212 223
213 js_sync_manager_observer_.OnEncryptedTypesChanged( 224 js_sync_manager_observer_.OnEncryptedTypesChanged(
214 encrypted_types, encrypt_everything); 225 encrypted_types, encrypt_everything);
215 PumpLoop(); 226 PumpLoop();
216 } 227 }
217 228
218 } // namespace 229 } // namespace
219 } // namespace browser_sync 230 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698