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

Side by Side Diff: components/sync/engine_impl/js_sync_encryption_handler_observer_unittest.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Rebase Created 3 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
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 "components/sync/engine_impl/js_sync_encryption_handler_observer.h" 5 #include "components/sync/engine_impl/js_sync_encryption_handler_observer.h"
6 6
7 #include <utility>
8
7 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 11 #include "base/run_loop.h"
9 #include "base/test/scoped_task_environment.h" 12 #include "base/test/scoped_task_environment.h"
10 #include "base/values.h" 13 #include "base/values.h"
11 #include "components/sync/base/cryptographer.h" 14 #include "components/sync/base/cryptographer.h"
12 #include "components/sync/base/fake_encryptor.h" 15 #include "components/sync/base/fake_encryptor.h"
13 #include "components/sync/base/model_type.h" 16 #include "components/sync/base/model_type.h"
14 #include "components/sync/base/passphrase_type.h" 17 #include "components/sync/base/passphrase_type.h"
15 #include "components/sync/base/time.h" 18 #include "components/sync/base/time.h"
16 #include "components/sync/engine/sync_string_conversions.h" 19 #include "components/sync/engine/sync_string_conversions.h"
17 #include "components/sync/js/js_event_details.h" 20 #include "components/sync/js/js_event_details.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 EXPECT_CALL(mock_js_event_handler_, 100 EXPECT_CALL(mock_js_event_handler_,
98 HandleJsEvent("onBootstrapTokenUpdated", 101 HandleJsEvent("onBootstrapTokenUpdated",
99 HasDetailsAsDictionary(bootstrap_token_details))); 102 HasDetailsAsDictionary(bootstrap_token_details)));
100 103
101 js_sync_encryption_handler_observer_.OnBootstrapTokenUpdated( 104 js_sync_encryption_handler_observer_.OnBootstrapTokenUpdated(
102 "sensitive_token", PASSPHRASE_BOOTSTRAP_TOKEN); 105 "sensitive_token", PASSPHRASE_BOOTSTRAP_TOKEN);
103 PumpLoop(); 106 PumpLoop();
104 } 107 }
105 108
106 TEST_F(JsSyncEncryptionHandlerObserverTest, OnEncryptedTypesChanged) { 109 TEST_F(JsSyncEncryptionHandlerObserverTest, OnEncryptedTypesChanged) {
107 base::DictionaryValue expected_details; 110 auto encrypted_type_values = base::MakeUnique<base::ListValue>();
108 base::ListValue* encrypted_type_values = new base::ListValue();
109 const bool encrypt_everything = false;
110 expected_details.Set("encryptedTypes", encrypted_type_values);
111 expected_details.SetBoolean("encryptEverything", encrypt_everything);
112 ModelTypeSet encrypted_types; 111 ModelTypeSet encrypted_types;
113 112
114 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 113 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
115 ModelType type = ModelTypeFromInt(i); 114 ModelType type = ModelTypeFromInt(i);
116 encrypted_types.Put(type); 115 encrypted_types.Put(type);
117 encrypted_type_values->AppendString(ModelTypeToString(type)); 116 encrypted_type_values->AppendString(ModelTypeToString(type));
118 } 117 }
119 118
119 base::DictionaryValue expected_details;
120 const bool encrypt_everything = false;
vabr (Chromium) 2017/06/01 19:53:33 optional nit: Should this actually be kEncryptEver
jdoerrie 2017/06/02 09:39:56 Done.
121 expected_details.Set("encryptedTypes", std::move(encrypted_type_values));
122 expected_details.SetBoolean("encryptEverything", encrypt_everything);
123
120 EXPECT_CALL(mock_js_event_handler_, 124 EXPECT_CALL(mock_js_event_handler_,
121 HandleJsEvent("onEncryptedTypesChanged", 125 HandleJsEvent("onEncryptedTypesChanged",
122 HasDetailsAsDictionary(expected_details))); 126 HasDetailsAsDictionary(expected_details)));
123 127
124 js_sync_encryption_handler_observer_.OnEncryptedTypesChanged( 128 js_sync_encryption_handler_observer_.OnEncryptedTypesChanged(
125 encrypted_types, encrypt_everything); 129 encrypted_types, encrypt_everything);
126 PumpLoop(); 130 PumpLoop();
127 } 131 }
128 132
129 TEST_F(JsSyncEncryptionHandlerObserverTest, OnCryptographerStateChanged) { 133 TEST_F(JsSyncEncryptionHandlerObserverTest, OnCryptographerStateChanged) {
(...skipping 27 matching lines...) Expand all
157 HandleJsEvent("onPassphraseTypeChanged", 161 HandleJsEvent("onPassphraseTypeChanged",
158 HasDetailsAsDictionary(passphrase_type_details))); 162 HasDetailsAsDictionary(passphrase_type_details)));
159 163
160 js_sync_encryption_handler_observer_.OnPassphraseTypeChanged( 164 js_sync_encryption_handler_observer_.OnPassphraseTypeChanged(
161 PassphraseType::IMPLICIT_PASSPHRASE, ProtoTimeToTime(10)); 165 PassphraseType::IMPLICIT_PASSPHRASE, ProtoTimeToTime(10));
162 PumpLoop(); 166 PumpLoop();
163 } 167 }
164 168
165 } // namespace 169 } // namespace
166 } // namespace syncer 170 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698