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