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

Side by Side Diff: extensions/browser/api/printer_provider/printer_provider_apitest.cc

Issue 902643002: Revert "Enable positional parameters for base::vsnprintf and base::vswprintf on Windows." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: extension Created 5 years, 10 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
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | remoting/host/ipc_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/json/json_string_value_serializer.h" 6 #include "base/json/json_string_value_serializer.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "extensions/browser/api/printer_provider/printer_provider_api.h" 9 #include "extensions/browser/api/printer_provider/printer_provider_api.h"
10 #include "extensions/common/extension.h" 10 #include "extensions/common/extension.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 &printers, run_loop.QuitClosure())); 260 &printers, run_loop.QuitClosure()));
261 261
262 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 262 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
263 263
264 run_loop.Run(); 264 run_loop.Run();
265 265
266 std::vector<std::string> expected_printers; 266 std::vector<std::string> expected_printers;
267 expected_printers.push_back(base::StringPrintf( 267 expected_printers.push_back(base::StringPrintf(
268 "{" 268 "{"
269 "\"description\":\"Test printer\"," 269 "\"description\":\"Test printer\","
270 "\"extensionId\":\"%1$s\"," 270 "\"extensionId\":\"%s\","
271 "\"id\":\"%1$s:printer1\"," 271 "\"id\":\"%s:printer1\","
272 "\"name\":\"Printer 1\"" 272 "\"name\":\"Printer 1\""
273 "}", 273 "}",
274 extension_id.c_str())); 274 extension_id.c_str(), extension_id.c_str()));
275 expected_printers.push_back(base::StringPrintf( 275 expected_printers.push_back(base::StringPrintf(
276 "{" 276 "{"
277 "\"extensionId\":\"%1$s\"," 277 "\"extensionId\":\"%s\","
278 "\"id\":\"%1$s:printerNoDesc\"," 278 "\"id\":\"%s:printerNoDesc\","
279 "\"name\":\"Printer 2\"" 279 "\"name\":\"Printer 2\""
280 "}", 280 "}",
281 extension_id.c_str())); 281 extension_id.c_str(), extension_id.c_str()));
282 282
283 ValidatePrinterListValue(printers, expected_printers); 283 ValidatePrinterListValue(printers, expected_printers);
284 } 284 }
285 285
286 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetPrintersAsyncSuccess) { 286 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetPrintersAsyncSuccess) {
287 extensions::ResultCatcher catcher; 287 extensions::ResultCatcher catcher;
288 288
289 std::string extension_id; 289 std::string extension_id;
290 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers", 290 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers",
291 "ASYNC_RESPONSE", &extension_id); 291 "ASYNC_RESPONSE", &extension_id);
292 ASSERT_FALSE(extension_id.empty()); 292 ASSERT_FALSE(extension_id.empty());
293 293
294 base::RunLoop run_loop; 294 base::RunLoop run_loop;
295 base::ListValue printers; 295 base::ListValue printers;
296 296
297 StartGetPrintersRequest(base::Bind(&AppendPrintersAndRunCallbackIfDone, 297 StartGetPrintersRequest(base::Bind(&AppendPrintersAndRunCallbackIfDone,
298 &printers, run_loop.QuitClosure())); 298 &printers, run_loop.QuitClosure()));
299 299
300 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 300 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
301 301
302 run_loop.Run(); 302 run_loop.Run();
303 303
304 std::vector<std::string> expected_printers; 304 std::vector<std::string> expected_printers;
305 expected_printers.push_back(base::StringPrintf( 305 expected_printers.push_back(base::StringPrintf(
306 "{" 306 "{"
307 "\"description\":\"Test printer\"," 307 "\"description\":\"Test printer\","
308 "\"extensionId\":\"%1$s\"," 308 "\"extensionId\":\"%s\","
309 "\"id\":\"%1$s:printer1\"," 309 "\"id\":\"%s:printer1\","
310 "\"name\":\"Printer 1\"" 310 "\"name\":\"Printer 1\""
311 "}", 311 "}",
312 extension_id.c_str())); 312 extension_id.c_str(), extension_id.c_str()));
313 313
314 ValidatePrinterListValue(printers, expected_printers); 314 ValidatePrinterListValue(printers, expected_printers);
315 } 315 }
316 316
317 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetPrintersTwoExtensions) { 317 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetPrintersTwoExtensions) {
318 extensions::ResultCatcher catcher; 318 extensions::ResultCatcher catcher;
319 319
320 std::string extension_id_1; 320 std::string extension_id_1;
321 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers", 321 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers",
322 "OK", &extension_id_1); 322 "OK", &extension_id_1);
(...skipping 13 matching lines...) Expand all
336 336
337 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 337 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
338 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 338 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
339 339
340 run_loop.Run(); 340 run_loop.Run();
341 341
342 std::vector<std::string> expected_printers; 342 std::vector<std::string> expected_printers;
343 expected_printers.push_back(base::StringPrintf( 343 expected_printers.push_back(base::StringPrintf(
344 "{" 344 "{"
345 "\"description\":\"Test printer\"," 345 "\"description\":\"Test printer\","
346 "\"extensionId\":\"%1$s\"," 346 "\"extensionId\":\"%s\","
347 "\"id\":\"%1$s:printer1\"," 347 "\"id\":\"%s:printer1\","
348 "\"name\":\"Printer 1\"" 348 "\"name\":\"Printer 1\""
349 "}", 349 "}",
350 extension_id_1.c_str())); 350 extension_id_1.c_str(), extension_id_1.c_str()));
351 expected_printers.push_back(base::StringPrintf( 351 expected_printers.push_back(base::StringPrintf(
352 "{" 352 "{"
353 "\"extensionId\":\"%1$s\"," 353 "\"extensionId\":\"%s\","
354 "\"id\":\"%1$s:printerNoDesc\"," 354 "\"id\":\"%s:printerNoDesc\","
355 "\"name\":\"Printer 2\"" 355 "\"name\":\"Printer 2\""
356 "}", 356 "}",
357 extension_id_1.c_str())); 357 extension_id_1.c_str(), extension_id_1.c_str()));
358 expected_printers.push_back(base::StringPrintf( 358 expected_printers.push_back(base::StringPrintf(
359 "{" 359 "{"
360 "\"description\":\"Test printer\"," 360 "\"description\":\"Test printer\","
361 "\"extensionId\":\"%1$s\"," 361 "\"extensionId\":\"%s\","
362 "\"id\":\"%1$s:printer1\"," 362 "\"id\":\"%s:printer1\","
363 "\"name\":\"Printer 1\"" 363 "\"name\":\"Printer 1\""
364 "}", 364 "}",
365 extension_id_2.c_str())); 365 extension_id_2.c_str(), extension_id_2.c_str()));
366 expected_printers.push_back(base::StringPrintf( 366 expected_printers.push_back(base::StringPrintf(
367 "{" 367 "{"
368 "\"extensionId\":\"%1$s\"," 368 "\"extensionId\":\"%s\","
369 "\"id\":\"%1$s:printerNoDesc\"," 369 "\"id\":\"%s:printerNoDesc\","
370 "\"name\":\"Printer 2\"" 370 "\"name\":\"Printer 2\""
371 "}", 371 "}",
372 extension_id_2.c_str())); 372 extension_id_2.c_str(), extension_id_2.c_str()));
373 373
374 ValidatePrinterListValue(printers, expected_printers); 374 ValidatePrinterListValue(printers, expected_printers);
375 } 375 }
376 376
377 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, 377 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest,
378 GetPrintersTwoExtensionsOneFails) { 378 GetPrintersTwoExtensionsOneFails) {
379 extensions::ResultCatcher catcher; 379 extensions::ResultCatcher catcher;
380 380
381 std::string extension_id_1; 381 std::string extension_id_1;
382 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers", 382 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers",
(...skipping 14 matching lines...) Expand all
397 397
398 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 398 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
399 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 399 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
400 400
401 run_loop.Run(); 401 run_loop.Run();
402 402
403 std::vector<std::string> expected_printers; 403 std::vector<std::string> expected_printers;
404 expected_printers.push_back(base::StringPrintf( 404 expected_printers.push_back(base::StringPrintf(
405 "{" 405 "{"
406 "\"description\":\"Test printer\"," 406 "\"description\":\"Test printer\","
407 "\"extensionId\":\"%1$s\"," 407 "\"extensionId\":\"%s\","
408 "\"id\":\"%1$s:printer1\"," 408 "\"id\":\"%s:printer1\","
409 "\"name\":\"Printer 1\"" 409 "\"name\":\"Printer 1\""
410 "}", 410 "}",
411 extension_id_2.c_str())); 411 extension_id_2.c_str(), extension_id_2.c_str()));
412 expected_printers.push_back(base::StringPrintf( 412 expected_printers.push_back(base::StringPrintf(
413 "{" 413 "{"
414 "\"extensionId\":\"%1$s\"," 414 "\"extensionId\":\"%s\","
415 "\"id\":\"%1$s:printerNoDesc\"," 415 "\"id\":\"%s:printerNoDesc\","
416 "\"name\":\"Printer 2\"" 416 "\"name\":\"Printer 2\""
417 "}", 417 "}",
418 extension_id_2.c_str())); 418 extension_id_2.c_str(), extension_id_2.c_str()));
419 419
420 ValidatePrinterListValue(printers, expected_printers); 420 ValidatePrinterListValue(printers, expected_printers);
421 } 421 }
422 422
423 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, 423 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest,
424 GetPrintersTwoExtensionsOneWithNoListener) { 424 GetPrintersTwoExtensionsOneWithNoListener) {
425 extensions::ResultCatcher catcher; 425 extensions::ResultCatcher catcher;
426 426
427 std::string extension_id_1; 427 std::string extension_id_1;
428 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers", 428 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers",
(...skipping 14 matching lines...) Expand all
443 443
444 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 444 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
445 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 445 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
446 446
447 run_loop.Run(); 447 run_loop.Run();
448 448
449 std::vector<std::string> expected_printers; 449 std::vector<std::string> expected_printers;
450 expected_printers.push_back(base::StringPrintf( 450 expected_printers.push_back(base::StringPrintf(
451 "{" 451 "{"
452 "\"description\":\"Test printer\"," 452 "\"description\":\"Test printer\","
453 "\"extensionId\":\"%1$s\"," 453 "\"extensionId\":\"%s\","
454 "\"id\":\"%1$s:printer1\"," 454 "\"id\":\"%s:printer1\","
455 "\"name\":\"Printer 1\"" 455 "\"name\":\"Printer 1\""
456 "}", 456 "}",
457 extension_id_2.c_str())); 457 extension_id_2.c_str(), extension_id_2.c_str()));
458 expected_printers.push_back(base::StringPrintf( 458 expected_printers.push_back(base::StringPrintf(
459 "{" 459 "{"
460 "\"extensionId\":\"%1$s\"," 460 "\"extensionId\":\"%s\","
461 "\"id\":\"%1$s:printerNoDesc\"," 461 "\"id\":\"%s:printerNoDesc\","
462 "\"name\":\"Printer 2\"" 462 "\"name\":\"Printer 2\""
463 "}", 463 "}",
464 extension_id_2.c_str())); 464 extension_id_2.c_str(), extension_id_2.c_str()));
465 465
466 ValidatePrinterListValue(printers, expected_printers); 466 ValidatePrinterListValue(printers, expected_printers);
467 } 467 }
468 468
469 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetPrintersNoListener) { 469 IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetPrintersNoListener) {
470 extensions::ResultCatcher catcher; 470 extensions::ResultCatcher catcher;
471 471
472 std::string extension_id; 472 std::string extension_id;
473 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers", 473 InitializePrinterProviderTestApp("api_test/printer_provider/request_printers",
474 "NO_LISTENER", &extension_id); 474 "NO_LISTENER", &extension_id);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 &printers, run_loop.QuitClosure())); 545 &printers, run_loop.QuitClosure()));
546 546
547 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 547 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
548 548
549 run_loop.Run(); 549 run_loop.Run();
550 550
551 EXPECT_TRUE(printers.empty()); 551 EXPECT_TRUE(printers.empty());
552 } 552 }
553 553
554 } // namespace 554 } // namespace
OLDNEW
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | remoting/host/ipc_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698