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

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

Issue 10827266: [Sync] Add SyncEncryptionHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Created 8 years, 4 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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("onStopSyncingPermanently", 51 HandleJsEvent("onStopSyncingPermanently",
52 HasDetails(JsEventDetails()))); 52 HasDetails(JsEventDetails())));
53 EXPECT_CALL(mock_js_event_handler_,
54 HandleJsEvent("onEncryptionComplete",
55 HasDetails(JsEventDetails())));
56 53
57 js_sync_manager_observer_.OnStopSyncingPermanently(); 54 js_sync_manager_observer_.OnStopSyncingPermanently();
58 js_sync_manager_observer_.OnEncryptionComplete();
59 PumpLoop(); 55 PumpLoop();
60 } 56 }
61 57
62 TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) { 58 TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) {
63 DictionaryValue expected_details; 59 DictionaryValue expected_details;
64 syncer::ModelTypeSet restored_types; 60 syncer::ModelTypeSet restored_types;
65 restored_types.Put(BOOKMARKS); 61 restored_types.Put(BOOKMARKS);
66 restored_types.Put(NIGORI); 62 restored_types.Put(NIGORI);
67 expected_details.Set("restoredTypes", ModelTypeSetToValue(restored_types)); 63 expected_details.Set("restoredTypes", ModelTypeSetToValue(restored_types));
68 64
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 ConnectionStatusToString(kStatus)); 122 ConnectionStatusToString(kStatus));
127 123
128 EXPECT_CALL(mock_js_event_handler_, 124 EXPECT_CALL(mock_js_event_handler_,
129 HandleJsEvent("onConnectionStatusChange", 125 HandleJsEvent("onConnectionStatusChange",
130 HasDetailsAsDictionary(expected_details))); 126 HasDetailsAsDictionary(expected_details)));
131 127
132 js_sync_manager_observer_.OnConnectionStatusChange(kStatus); 128 js_sync_manager_observer_.OnConnectionStatusChange(kStatus);
133 PumpLoop(); 129 PumpLoop();
134 } 130 }
135 131
136 TEST_F(JsSyncManagerObserverTest, OnPassphraseRequired) {
137 InSequence dummy;
138
139 DictionaryValue reason_passphrase_not_required_details;
140 DictionaryValue reason_encryption_details;
141 DictionaryValue reason_decryption_details;
142
143 reason_passphrase_not_required_details.SetString(
144 "reason",
145 PassphraseRequiredReasonToString(REASON_PASSPHRASE_NOT_REQUIRED));
146 reason_encryption_details.SetString(
147 "reason",
148 PassphraseRequiredReasonToString(REASON_ENCRYPTION));
149 reason_decryption_details.SetString(
150 "reason",
151 PassphraseRequiredReasonToString(REASON_DECRYPTION));
152
153 EXPECT_CALL(mock_js_event_handler_,
154 HandleJsEvent("onPassphraseRequired",
155 HasDetailsAsDictionary(
156 reason_passphrase_not_required_details)));
157 EXPECT_CALL(mock_js_event_handler_,
158 HandleJsEvent("onPassphraseRequired",
159 HasDetailsAsDictionary(reason_encryption_details)));
160 EXPECT_CALL(mock_js_event_handler_,
161 HandleJsEvent("onPassphraseRequired",
162 HasDetailsAsDictionary(reason_decryption_details)));
163
164 js_sync_manager_observer_.OnPassphraseRequired(
165 REASON_PASSPHRASE_NOT_REQUIRED,
166 sync_pb::EncryptedData());
167 js_sync_manager_observer_.OnPassphraseRequired(REASON_ENCRYPTION,
168 sync_pb::EncryptedData());
169 js_sync_manager_observer_.OnPassphraseRequired(REASON_DECRYPTION,
170 sync_pb::EncryptedData());
171 PumpLoop();
172 }
173
174 TEST_F(JsSyncManagerObserverTest, SensitiveNotifiations) { 132 TEST_F(JsSyncManagerObserverTest, SensitiveNotifiations) {
175 DictionaryValue redacted_token_details; 133 DictionaryValue redacted_token_details;
176 redacted_token_details.SetString("token", "<redacted>"); 134 redacted_token_details.SetString("token", "<redacted>");
177 DictionaryValue redacted_bootstrap_token_details; 135 DictionaryValue redacted_bootstrap_token_details;
178 redacted_bootstrap_token_details.SetString("bootstrapToken", "<redacted>"); 136 redacted_bootstrap_token_details.SetString("bootstrapToken", "<redacted>");
179 137
180 EXPECT_CALL(mock_js_event_handler_, 138 EXPECT_CALL(mock_js_event_handler_,
181 HandleJsEvent("onUpdatedToken", 139 HandleJsEvent("onUpdatedToken",
182 HasDetailsAsDictionary(redacted_token_details))); 140 HasDetailsAsDictionary(redacted_token_details)));
183 EXPECT_CALL(mock_js_event_handler_,
184 HandleJsEvent(
185 "OnBootstrapTokenUpdated",
186 HasDetailsAsDictionary(redacted_bootstrap_token_details)));
187 141
188 js_sync_manager_observer_.OnUpdatedToken("sensitive_token"); 142 js_sync_manager_observer_.OnUpdatedToken("sensitive_token");
189 js_sync_manager_observer_.OnBootstrapTokenUpdated("sensitive_token");
190 PumpLoop(); 143 PumpLoop();
191 } 144 }
192 145
193 TEST_F(JsSyncManagerObserverTest, OnEncryptedTypesChanged) {
194 DictionaryValue expected_details;
195 ListValue* encrypted_type_values = new ListValue();
196 const bool encrypt_everything = false;
197 expected_details.Set("encryptedTypes", encrypted_type_values);
198 expected_details.SetBoolean("encryptEverything", encrypt_everything);
199 ModelTypeSet encrypted_types;
200
201 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
202 ModelType type = ModelTypeFromInt(i);
203 encrypted_types.Put(type);
204 encrypted_type_values->Append(Value::CreateStringValue(
205 ModelTypeToString(type)));
206 }
207
208 EXPECT_CALL(mock_js_event_handler_,
209 HandleJsEvent("onEncryptedTypesChanged",
210 HasDetailsAsDictionary(expected_details)));
211
212 js_sync_manager_observer_.OnEncryptedTypesChanged(
213 encrypted_types, encrypt_everything);
214 PumpLoop();
215 }
216
217 } // namespace 146 } // namespace
218 } // namespace syncer 147 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/js_sync_manager_observer.cc ('k') | sync/internal_api/public/sync_encryption_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698