OLD | NEW |
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 // 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 465 |
466 // Stops UI loop after desired status is updated. | 466 // Stops UI loop after desired status is updated. |
467 void StopUILoop() { | 467 void StopUILoop() { |
468 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 468 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
469 base::MessageLoopForUI::current()->Quit(); | 469 base::MessageLoopForUI::current()->Quit(); |
470 } | 470 } |
471 | 471 |
472 // Fetch a URL. If message_loop_started is true, starts the message loop | 472 // Fetch a URL. If message_loop_started is true, starts the message loop |
473 // so the caller could wait till OnURLFetchComplete is called. | 473 // so the caller could wait till OnURLFetchComplete is called. |
474 net::URLRequestStatus::Status FetchUrl(const GURL& url) { | 474 net::URLRequestStatus::Status FetchUrl(const GURL& url) { |
475 url_fetcher_.reset(net::URLFetcher::Create( | 475 url_fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); |
476 url, net::URLFetcher::GET, this)); | |
477 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 476 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
478 url_fetcher_->SetRequestContext(request_context_); | 477 url_fetcher_->SetRequestContext(request_context_); |
479 url_fetcher_->Start(); | 478 url_fetcher_->Start(); |
480 content::RunMessageLoop(); | 479 content::RunMessageLoop(); |
481 return response_status_; | 480 return response_status_; |
482 } | 481 } |
483 | 482 |
484 base::OneShotTimer<SafeBrowsingServerTestHelper> check_update_timer_; | 483 base::OneShotTimer<SafeBrowsingServerTestHelper> check_update_timer_; |
485 SafeBrowsingServerTest* safe_browsing_test_; | 484 SafeBrowsingServerTest* safe_browsing_test_; |
486 scoped_ptr<net::URLFetcher> url_fetcher_; | 485 scoped_ptr<net::URLFetcher> url_fetcher_; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 safe_browsing_helper->FetchDBToVerify(test_server(), step)); | 568 safe_browsing_helper->FetchDBToVerify(test_server(), step)); |
570 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); | 569 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); |
571 last_step = step; | 570 last_step = step; |
572 } | 571 } |
573 | 572 |
574 // Verifies with server if test is done and waits till server responses. | 573 // Verifies with server if test is done and waits till server responses. |
575 EXPECT_EQ(net::URLRequestStatus::SUCCESS, | 574 EXPECT_EQ(net::URLRequestStatus::SUCCESS, |
576 safe_browsing_helper->VerifyTestComplete(test_server(), last_step)); | 575 safe_browsing_helper->VerifyTestComplete(test_server(), last_step)); |
577 EXPECT_EQ("yes", safe_browsing_helper->response_data()); | 576 EXPECT_EQ("yes", safe_browsing_helper->response_data()); |
578 } | 577 } |
OLD | NEW |