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

Side by Side Diff: content/browser/worker_host/test/worker_browsertest.cc

Issue 12767006: [Cleanup] Remove StringPrintf from global namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, once more Created 7 years, 9 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 344 }
345 345
346 #if defined(OS_LINUX) || defined(OS_CHROMEOS) 346 #if defined(OS_LINUX) || defined(OS_CHROMEOS)
347 // This test is flaky inside the Linux SUID sandbox. 347 // This test is flaky inside the Linux SUID sandbox.
348 // http://crbug.com/130116 348 // http://crbug.com/130116
349 IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_LimitPerPage) { 349 IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_LimitPerPage) {
350 #else 350 #else
351 IN_PROC_BROWSER_TEST_F(WorkerTest, LimitPerPage) { 351 IN_PROC_BROWSER_TEST_F(WorkerTest, LimitPerPage) {
352 #endif 352 #endif
353 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate; 353 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
354 std::string query = StringPrintf("?count=%d", max_workers_per_tab + 1); 354 std::string query = base::StringPrintf("?count=%d", max_workers_per_tab + 1);
355 355
356 GURL url = GetTestURL("many_shared_workers.html", query); 356 GURL url = GetTestURL("many_shared_workers.html", query);
357 NavigateToURL(shell(), url); 357 NavigateToURL(shell(), url);
358 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); 358 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab));
359 } 359 }
360 360
361 #if defined(OS_LINUX) || defined(OS_CHROMEOS) 361 #if defined(OS_LINUX) || defined(OS_CHROMEOS)
362 // This test is flaky inside the Linux SUID sandbox. 362 // This test is flaky inside the Linux SUID sandbox.
363 // http://crbug.com/130116 363 // http://crbug.com/130116
364 IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_LimitTotal) { 364 IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_LimitTotal) {
365 #else 365 #else
366 // http://crbug.com/36800 366 // http://crbug.com/36800
367 IN_PROC_BROWSER_TEST_F(WorkerTest, LimitTotal) { 367 IN_PROC_BROWSER_TEST_F(WorkerTest, LimitTotal) {
368 #endif 368 #endif
369 if (base::SysInfo::AmountOfPhysicalMemoryMB() < 8192) { 369 if (base::SysInfo::AmountOfPhysicalMemoryMB() < 8192) {
370 LOG(INFO) << "WorkerTest.LimitTotal not running because it needs 8 GB RAM."; 370 LOG(INFO) << "WorkerTest.LimitTotal not running because it needs 8 GB RAM.";
371 return; 371 return;
372 } 372 }
373 373
374 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate; 374 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
375 int total_workers = WorkerServiceImpl::kMaxWorkersWhenSeparate; 375 int total_workers = WorkerServiceImpl::kMaxWorkersWhenSeparate;
376 376
377 std::string query = StringPrintf("?count=%d", max_workers_per_tab); 377 std::string query = base::StringPrintf("?count=%d", max_workers_per_tab);
378 GURL url = GetTestURL("many_shared_workers.html", query); 378 GURL url = GetTestURL("many_shared_workers.html", query);
379 NavigateToURL(shell(), GURL(url.spec() + StringPrintf("&client_id=0"))); 379 NavigateToURL(shell(),
380 GURL(url.spec() + base::StringPrintf("&client_id=0")));
380 381
381 // Adding 1 so that we cause some workers to be queued. 382 // Adding 1 so that we cause some workers to be queued.
382 int tab_count = (total_workers / max_workers_per_tab) + 1; 383 int tab_count = (total_workers / max_workers_per_tab) + 1;
383 for (int i = 1; i < tab_count; ++i) { 384 for (int i = 1; i < tab_count; ++i) {
384 NavigateToURL( 385 NavigateToURL(
385 CreateBrowser(), GURL(url.spec() + StringPrintf("&client_id=%d", i))); 386 CreateBrowser(),
387 GURL(url.spec() + base::StringPrintf("&client_id=%d", i)));
386 } 388 }
387 389
388 // Check that we didn't create more than the max number of workers. 390 // Check that we didn't create more than the max number of workers.
389 ASSERT_TRUE(WaitForWorkerProcessCount(total_workers)); 391 ASSERT_TRUE(WaitForWorkerProcessCount(total_workers));
390 392
391 // Now close a page and check that the queued workers were started. 393 // Now close a page and check that the queued workers were started.
392 url = GURL(GetTestUrl("google", "google.html")); 394 url = GURL(GetTestUrl("google", "google.html"));
393 NavigateToURL(shell(), url); 395 NavigateToURL(shell(), url);
394 396
395 ASSERT_TRUE(WaitForWorkerProcessCount(total_workers)); 397 ASSERT_TRUE(WaitForWorkerProcessCount(total_workers));
396 } 398 }
397 399
398 // Flaky, http://crbug.com/59786. 400 // Flaky, http://crbug.com/59786.
399 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerClose) { 401 IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerClose) {
400 RunTest("worker_close.html", ""); 402 RunTest("worker_close.html", "");
401 ASSERT_TRUE(WaitForWorkerProcessCount(0)); 403 ASSERT_TRUE(WaitForWorkerProcessCount(0));
402 } 404 }
403 405
404 // Flaky, http://crbug.com/70861. 406 // Flaky, http://crbug.com/70861.
405 IN_PROC_BROWSER_TEST_F(WorkerTest, QueuedSharedWorkerShutdown) { 407 IN_PROC_BROWSER_TEST_F(WorkerTest, QueuedSharedWorkerShutdown) {
406 // Tests to make sure that queued shared workers are started up when shared 408 // Tests to make sure that queued shared workers are started up when shared
407 // workers shut down. 409 // workers shut down.
408 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate; 410 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
409 std::string query = StringPrintf("?count=%d", max_workers_per_tab); 411 std::string query = base::StringPrintf("?count=%d", max_workers_per_tab);
410 RunTest("queued_shared_worker_shutdown.html", query); 412 RunTest("queued_shared_worker_shutdown.html", query);
411 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); 413 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab));
412 } 414 }
413 415
414 // Flaky, http://crbug.com/69881. 416 // Flaky, http://crbug.com/69881.
415 // Sometimes triggers 417 // Sometimes triggers
416 // Check failed: message_ports_[message_port_id].queued_messages.empty(). 418 // Check failed: message_ports_[message_port_id].queued_messages.empty().
417 IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_MultipleTabsQueuedSharedWorker) { 419 IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_MultipleTabsQueuedSharedWorker) {
418 // Tests to make sure that only one instance of queued shared workers are 420 // Tests to make sure that only one instance of queued shared workers are
419 // started up even when those instances are on multiple tabs. 421 // started up even when those instances are on multiple tabs.
420 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate; 422 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
421 std::string query = StringPrintf("?count=%d", max_workers_per_tab + 1); 423 std::string query = base::StringPrintf("?count=%d", max_workers_per_tab + 1);
422 GURL url = GetTestURL("many_shared_workers.html", query); 424 GURL url = GetTestURL("many_shared_workers.html", query);
423 NavigateToURL(shell(), url); 425 NavigateToURL(shell(), url);
424 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); 426 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab));
425 427
426 // Create same set of workers in new tab (leaves one worker queued from this 428 // Create same set of workers in new tab (leaves one worker queued from this
427 // tab). 429 // tab).
428 url = GetTestURL("many_shared_workers.html", query); 430 url = GetTestURL("many_shared_workers.html", query);
429 NavigateToURL(CreateBrowser(), url); 431 NavigateToURL(CreateBrowser(), url);
430 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); 432 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab));
431 433
432 // Now shutdown one of the shared workers - this will fire both queued 434 // Now shutdown one of the shared workers - this will fire both queued
433 // workers, but only one instance should be started. 435 // workers, but only one instance should be started.
434 url = GetTestURL("shutdown_shared_worker.html", "?id=0"); 436 url = GetTestURL("shutdown_shared_worker.html", "?id=0");
435 NavigateToURL(CreateBrowser(), url); 437 NavigateToURL(CreateBrowser(), url);
436 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); 438 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab));
437 } 439 }
438 440
439 // Flaky: http://crbug.com/48148 441 // Flaky: http://crbug.com/48148
440 IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_QueuedSharedWorkerStartedFromOtherTa b) { 442 IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_QueuedSharedWorkerStartedFromOtherTa b) {
441 // Tests to make sure that queued shared workers are started up when 443 // Tests to make sure that queued shared workers are started up when
442 // an instance is launched from another tab. 444 // an instance is launched from another tab.
443 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate; 445 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
444 std::string query = StringPrintf("?count=%d", max_workers_per_tab + 1); 446 std::string query = base::StringPrintf("?count=%d", max_workers_per_tab + 1);
445 GURL url = GetTestURL("many_shared_workers.html", query); 447 GURL url = GetTestURL("many_shared_workers.html", query);
446 NavigateToURL(shell(), url); 448 NavigateToURL(shell(), url);
447 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); 449 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab));
448 450
449 // First window has hit its limit. Now launch second window which creates 451 // First window has hit its limit. Now launch second window which creates
450 // the same worker that was queued in the first window, to ensure it gets 452 // the same worker that was queued in the first window, to ensure it gets
451 // connected to the first window too. 453 // connected to the first window too.
452 query = StringPrintf("?id=%d", max_workers_per_tab); 454 query = base::StringPrintf("?id=%d", max_workers_per_tab);
453 url = GetTestURL("single_shared_worker.html", query); 455 url = GetTestURL("single_shared_worker.html", query);
454 NavigateToURL(CreateBrowser(), url); 456 NavigateToURL(CreateBrowser(), url);
455 457
456 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1)); 458 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1));
457 } 459 }
458 460
459 IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) { 461 IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) {
460 // Launch WebSocket server. 462 // Launch WebSocket server.
461 net::TestServer ws_server(net::TestServer::TYPE_WS, 463 net::TestServer ws_server(net::TestServer::TYPE_WS,
462 net::TestServer::kLocalhost, 464 net::TestServer::kLocalhost,
(...skipping 10 matching lines...) Expand all
473 // Run test. 475 // Run test.
474 Shell* window = shell(); 476 Shell* window = shell();
475 const string16 expected_title = ASCIIToUTF16("OK"); 477 const string16 expected_title = ASCIIToUTF16("OK");
476 TitleWatcher title_watcher(window->web_contents(), expected_title); 478 TitleWatcher title_watcher(window->web_contents(), expected_title);
477 NavigateToURL(window, url); 479 NavigateToURL(window, url);
478 string16 final_title = title_watcher.WaitAndGetTitle(); 480 string16 final_title = title_watcher.WaitAndGetTitle();
479 EXPECT_EQ(expected_title, final_title); 481 EXPECT_EQ(expected_title, final_title);
480 } 482 }
481 483
482 } // namespace content 484 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698