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

Side by Side Diff: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc

Issue 564043004: Remove implicit conversions from scoped_refptr to T* in extensions code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h" 8 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h"
9 #include "chrome/browser/extensions/extension_api_unittest.h" 9 #include "chrome/browser/extensions/extension_api_unittest.h"
10 #include "chrome/browser/extensions/extension_function_test_utils.h" 10 #include "chrome/browser/extensions/extension_function_test_utils.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 scoped_ptr<base::ListValue> args(new base::ListValue); 151 scoped_ptr<base::ListValue> args(new base::ListValue);
152 args->Append(StringToBinaryValue(private_key_1)); 152 args->Append(StringToBinaryValue(private_key_1));
153 args->Append(StringToBinaryValue(public_key_2)); 153 args->Append(StringToBinaryValue(public_key_2));
154 154
155 ASSERT_TRUE(extension_function_test_utils::RunFunction( 155 ASSERT_TRUE(extension_function_test_utils::RunFunction(
156 function.get(), 156 function.get(),
157 args.Pass(), 157 args.Pass(),
158 browser(), 158 browser(),
159 extension_function_test_utils::NONE)); 159 extension_function_test_utils::NONE));
160 160
161 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function)); 161 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
162 } 162 }
163 163
164 TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage) { 164 TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage) {
165 scoped_refptr<EasyUnlockPrivateCreateSecureMessageFunction> function( 165 scoped_refptr<EasyUnlockPrivateCreateSecureMessageFunction> function(
166 new EasyUnlockPrivateCreateSecureMessageFunction()); 166 new EasyUnlockPrivateCreateSecureMessageFunction());
167 function->set_has_callback(true); 167 function->set_has_callback(true);
168 168
169 std::string expected_result; 169 std::string expected_result;
170 client_->CreateSecureMessage( 170 client_->CreateSecureMessage(
171 "PAYLOAD", 171 "PAYLOAD",
(...skipping 24 matching lines...) Expand all
196 options->SetString( 196 options->SetString(
197 "signType", 197 "signType",
198 api::ToString(api::SIGNATURE_TYPE_HMAC_SHA256)); 198 api::ToString(api::SIGNATURE_TYPE_HMAC_SHA256));
199 199
200 ASSERT_TRUE(extension_function_test_utils::RunFunction( 200 ASSERT_TRUE(extension_function_test_utils::RunFunction(
201 function.get(), 201 function.get(),
202 args.Pass(), 202 args.Pass(),
203 browser(), 203 browser(),
204 extension_function_test_utils::NONE)); 204 extension_function_test_utils::NONE));
205 205
206 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function)); 206 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
207 } 207 }
208 208
209 TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_EmptyOptions) { 209 TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_EmptyOptions) {
210 scoped_refptr<EasyUnlockPrivateCreateSecureMessageFunction> function( 210 scoped_refptr<EasyUnlockPrivateCreateSecureMessageFunction> function(
211 new EasyUnlockPrivateCreateSecureMessageFunction()); 211 new EasyUnlockPrivateCreateSecureMessageFunction());
212 function->set_has_callback(true); 212 function->set_has_callback(true);
213 213
214 std::string expected_result; 214 std::string expected_result;
215 client_->CreateSecureMessage( 215 client_->CreateSecureMessage(
216 "PAYLOAD", 216 "PAYLOAD",
(...skipping 12 matching lines...) Expand all
229 args->Append(StringToBinaryValue("KEY")); 229 args->Append(StringToBinaryValue("KEY"));
230 base::DictionaryValue* options = new base::DictionaryValue(); 230 base::DictionaryValue* options = new base::DictionaryValue();
231 args->Append(options); 231 args->Append(options);
232 232
233 ASSERT_TRUE(extension_function_test_utils::RunFunction( 233 ASSERT_TRUE(extension_function_test_utils::RunFunction(
234 function.get(), 234 function.get(),
235 args.Pass(), 235 args.Pass(),
236 browser(), 236 browser(),
237 extension_function_test_utils::NONE)); 237 extension_function_test_utils::NONE));
238 238
239 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function)); 239 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
240 } 240 }
241 241
242 TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_AsymmetricSign) { 242 TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_AsymmetricSign) {
243 scoped_refptr<EasyUnlockPrivateCreateSecureMessageFunction> function( 243 scoped_refptr<EasyUnlockPrivateCreateSecureMessageFunction> function(
244 new EasyUnlockPrivateCreateSecureMessageFunction()); 244 new EasyUnlockPrivateCreateSecureMessageFunction());
245 function->set_has_callback(true); 245 function->set_has_callback(true);
246 246
247 std::string expected_result; 247 std::string expected_result;
248 client_->CreateSecureMessage( 248 client_->CreateSecureMessage(
249 "PAYLOAD", 249 "PAYLOAD",
(...skipping 19 matching lines...) Expand all
269 options->SetString( 269 options->SetString(
270 "signType", 270 "signType",
271 api::ToString(api::SIGNATURE_TYPE_ECDSA_P256_SHA256)); 271 api::ToString(api::SIGNATURE_TYPE_ECDSA_P256_SHA256));
272 272
273 ASSERT_TRUE(extension_function_test_utils::RunFunction( 273 ASSERT_TRUE(extension_function_test_utils::RunFunction(
274 function.get(), 274 function.get(),
275 args.Pass(), 275 args.Pass(),
276 browser(), 276 browser(),
277 extension_function_test_utils::NONE)); 277 extension_function_test_utils::NONE));
278 278
279 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function)); 279 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
280 } 280 }
281 281
282 TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage) { 282 TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage) {
283 scoped_refptr<EasyUnlockPrivateUnwrapSecureMessageFunction> function( 283 scoped_refptr<EasyUnlockPrivateUnwrapSecureMessageFunction> function(
284 new EasyUnlockPrivateUnwrapSecureMessageFunction()); 284 new EasyUnlockPrivateUnwrapSecureMessageFunction());
285 function->set_has_callback(true); 285 function->set_has_callback(true);
286 286
287 std::string expected_result; 287 std::string expected_result;
288 client_->UnwrapSecureMessage( 288 client_->UnwrapSecureMessage(
289 "PAYLOAD", 289 "PAYLOAD",
(...skipping 16 matching lines...) Expand all
306 options->SetString( 306 options->SetString(
307 "signType", 307 "signType",
308 api::ToString(api::SIGNATURE_TYPE_HMAC_SHA256)); 308 api::ToString(api::SIGNATURE_TYPE_HMAC_SHA256));
309 309
310 ASSERT_TRUE(extension_function_test_utils::RunFunction( 310 ASSERT_TRUE(extension_function_test_utils::RunFunction(
311 function.get(), 311 function.get(),
312 args.Pass(), 312 args.Pass(),
313 browser(), 313 browser(),
314 extension_function_test_utils::NONE)); 314 extension_function_test_utils::NONE));
315 315
316 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function)); 316 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
317 } 317 }
318 318
319 TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_EmptyOptions) { 319 TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_EmptyOptions) {
320 scoped_refptr<EasyUnlockPrivateUnwrapSecureMessageFunction> function( 320 scoped_refptr<EasyUnlockPrivateUnwrapSecureMessageFunction> function(
321 new EasyUnlockPrivateUnwrapSecureMessageFunction()); 321 new EasyUnlockPrivateUnwrapSecureMessageFunction());
322 function->set_has_callback(true); 322 function->set_has_callback(true);
323 323
324 std::string expected_result; 324 std::string expected_result;
325 client_->UnwrapSecureMessage( 325 client_->UnwrapSecureMessage(
326 "MESSAGE", 326 "MESSAGE",
327 "KEY", 327 "KEY",
328 "", // associated data 328 "", // associated data
329 easy_unlock::kEncryptionTypeNone, 329 easy_unlock::kEncryptionTypeNone,
330 easy_unlock::kSignatureTypeHMACSHA256, 330 easy_unlock::kSignatureTypeHMACSHA256,
331 base::Bind(&CopyData, &expected_result)); 331 base::Bind(&CopyData, &expected_result));
332 ASSERT_GT(expected_result.length(), 0u); 332 ASSERT_GT(expected_result.length(), 0u);
333 333
334 scoped_ptr<base::ListValue> args(new base::ListValue); 334 scoped_ptr<base::ListValue> args(new base::ListValue);
335 args->Append(StringToBinaryValue("MESSAGE")); 335 args->Append(StringToBinaryValue("MESSAGE"));
336 args->Append(StringToBinaryValue("KEY")); 336 args->Append(StringToBinaryValue("KEY"));
337 base::DictionaryValue* options = new base::DictionaryValue(); 337 base::DictionaryValue* options = new base::DictionaryValue();
338 args->Append(options); 338 args->Append(options);
339 339
340 ASSERT_TRUE(extension_function_test_utils::RunFunction( 340 ASSERT_TRUE(extension_function_test_utils::RunFunction(
341 function.get(), 341 function.get(),
342 args.Pass(), 342 args.Pass(),
343 browser(), 343 browser(),
344 extension_function_test_utils::NONE)); 344 extension_function_test_utils::NONE));
345 345
346 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function)); 346 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
347 } 347 }
348 348
349 TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_AsymmetricSign) { 349 TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_AsymmetricSign) {
350 scoped_refptr<EasyUnlockPrivateUnwrapSecureMessageFunction> function( 350 scoped_refptr<EasyUnlockPrivateUnwrapSecureMessageFunction> function(
351 new EasyUnlockPrivateUnwrapSecureMessageFunction()); 351 new EasyUnlockPrivateUnwrapSecureMessageFunction());
352 function->set_has_callback(true); 352 function->set_has_callback(true);
353 353
354 std::string expected_result; 354 std::string expected_result;
355 client_->UnwrapSecureMessage( 355 client_->UnwrapSecureMessage(
356 "MESSAGE", 356 "MESSAGE",
(...skipping 14 matching lines...) Expand all
371 options->SetString( 371 options->SetString(
372 "signType", 372 "signType",
373 api::ToString(api::SIGNATURE_TYPE_ECDSA_P256_SHA256)); 373 api::ToString(api::SIGNATURE_TYPE_ECDSA_P256_SHA256));
374 374
375 ASSERT_TRUE(extension_function_test_utils::RunFunction( 375 ASSERT_TRUE(extension_function_test_utils::RunFunction(
376 function.get(), 376 function.get(),
377 args.Pass(), 377 args.Pass(),
378 browser(), 378 browser(),
379 extension_function_test_utils::NONE)); 379 extension_function_test_utils::NONE));
380 380
381 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function)); 381 EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
382 } 382 }
383 383
384 } // namespace 384 } // namespace
385 385
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698