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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_test.cc

Issue 7744004: Avoid long test_server timeouts by using action_timeout_ms (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 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 | Annotate | Revision Log
« no previous file with comments | « base/test/test_timeouts.cc ('k') | net/test/test_server.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This test uses the safebrowsing test server published at 5 // This test uses the safebrowsing test server published at
6 // http://code.google.com/p/google-safe-browsing/ to test the safebrowsing 6 // http://code.google.com/p/google-safe-browsing/ to test the safebrowsing
7 // protocol implemetation. Details of the safebrowsing testing flow is 7 // protocol implemetation. Details of the safebrowsing testing flow is
8 // documented at 8 // documented at
9 // http://code.google.com/p/google-safe-browsing/wiki/ProtocolTesting 9 // http://code.google.com/p/google-safe-browsing/wiki/ProtocolTesting
10 // 10 //
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 GURL url(base::StringPrintf("http://%s:%d%s?test_step=0", 460 GURL url(base::StringPrintf("http://%s:%d%s?test_step=0",
461 host, port, kDBResetPath)); 461 host, port, kDBResetPath));
462 // TODO(lzheng): We should have a way to reliably tell when a server is 462 // TODO(lzheng): We should have a way to reliably tell when a server is
463 // ready so we could get rid of the Sleep and retry loop. 463 // ready so we could get rid of the Sleep and retry loop.
464 while (true) { 464 while (true) {
465 if (FetchUrl(url) == net::URLRequestStatus::SUCCESS) 465 if (FetchUrl(url) == net::URLRequestStatus::SUCCESS)
466 break; 466 break;
467 // Wait and try again if last fetch was failed. The loop will hit the 467 // Wait and try again if last fetch was failed. The loop will hit the
468 // timeout in OutOfProcTestRunner if the fetch can not get success 468 // timeout in OutOfProcTestRunner if the fetch can not get success
469 // response. 469 // response.
470 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); 470 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms());
471 } 471 }
472 } 472 }
473 473
474 // Calls test server to fetch database for verification. 474 // Calls test server to fetch database for verification.
475 net::URLRequestStatus::Status FetchDBToVerify(const char* host, int port, 475 net::URLRequestStatus::Status FetchDBToVerify(const char* host, int port,
476 int test_step) { 476 int test_step) {
477 // TODO(lzheng): Remove chunk_type=add once it is not needed by the server. 477 // TODO(lzheng): Remove chunk_type=add once it is not needed by the server.
478 GURL url(base::StringPrintf( 478 GURL url(base::StringPrintf(
479 "http://%s:%d%s?" 479 "http://%s:%d%s?"
480 "client=chromium&appver=1.0&pver=2.2&test_step=%d&" 480 "client=chromium&appver=1.0&pver=2.2&test_step=%d&"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 // Starts safebrowsing update on IO thread. Waits till scheduled 584 // Starts safebrowsing update on IO thread. Waits till scheduled
585 // update finishes. Stops waiting after kMaxWaitSecPerStep if the update 585 // update finishes. Stops waiting after kMaxWaitSecPerStep if the update
586 // could not finish. 586 // could not finish.
587 base::Time now = base::Time::Now(); 587 base::Time now = base::Time::Now();
588 SetTestStep(step); 588 SetTestStep(step);
589 safe_browsing_helper->ForceUpdate(); 589 safe_browsing_helper->ForceUpdate();
590 590
591 do { 591 do {
592 // Periodically pull the status. 592 // Periodically pull the status.
593 safe_browsing_helper->WaitForStatusUpdate( 593 safe_browsing_helper->WaitForStatusUpdate(
594 TestTimeouts::action_timeout_ms()); 594 TestTimeouts::tiny_timeout_ms());
595 } while (is_update_scheduled() || is_initial_request() || 595 } while (is_update_scheduled() || is_initial_request() ||
596 !is_database_ready()); 596 !is_database_ready());
597 597
598 598
599 if (last_update() < now) { 599 if (last_update() < now) {
600 // This means no data available anymore. 600 // This means no data available anymore.
601 break; 601 break;
602 } 602 }
603 603
604 // Fetches URLs to verify and waits till server responses with data. 604 // Fetches URLs to verify and waits till server responses with data.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } 642 }
643 643
644 // Verifies with server if test is done and waits till server responses. 644 // Verifies with server if test is done and waits till server responses.
645 EXPECT_EQ(net::URLRequestStatus::SUCCESS, 645 EXPECT_EQ(net::URLRequestStatus::SUCCESS,
646 safe_browsing_helper->VerifyTestComplete(server_host, 646 safe_browsing_helper->VerifyTestComplete(server_host,
647 server_port, 647 server_port,
648 last_step)); 648 last_step));
649 EXPECT_EQ("yes", safe_browsing_helper->response_data()); 649 EXPECT_EQ("yes", safe_browsing_helper->response_data());
650 test_server.Stop(); 650 test_server.Stop();
651 } 651 }
OLDNEW
« no previous file with comments | « base/test/test_timeouts.cc ('k') | net/test/test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698