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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 source->GetResponseAsString(&response_data_); | 508 source->GetResponseAsString(&response_data_); |
509 response_status_ = source->GetStatus().status(); | 509 response_status_ = source->GetStatus().status(); |
510 StopUILoop(); | 510 StopUILoop(); |
511 } | 511 } |
512 | 512 |
513 const std::string& response_data() { | 513 const std::string& response_data() { |
514 return response_data_; | 514 return response_data_; |
515 } | 515 } |
516 | 516 |
517 private: | 517 private: |
| 518 friend class base::RefCountedThreadSafe<SafeBrowsingServiceTestHelper>; |
| 519 virtual ~SafeBrowsingServiceTestHelper() {} |
| 520 |
518 // Stops UI loop after desired status is updated. | 521 // Stops UI loop after desired status is updated. |
519 void StopUILoop() { | 522 void StopUILoop() { |
520 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 523 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
521 MessageLoopForUI::current()->Quit(); | 524 MessageLoopForUI::current()->Quit(); |
522 } | 525 } |
523 | 526 |
524 // Fetch a URL. If message_loop_started is true, starts the message loop | 527 // Fetch a URL. If message_loop_started is true, starts the message loop |
525 // so the caller could wait till OnURLFetchComplete is called. | 528 // so the caller could wait till OnURLFetchComplete is called. |
526 net::URLRequestStatus::Status FetchUrl(const GURL& url) { | 529 net::URLRequestStatus::Status FetchUrl(const GURL& url) { |
527 url_fetcher_.reset(content::URLFetcher::Create( | 530 url_fetcher_.reset(content::URLFetcher::Create( |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 } | 641 } |
639 | 642 |
640 // Verifies with server if test is done and waits till server responses. | 643 // Verifies with server if test is done and waits till server responses. |
641 EXPECT_EQ(net::URLRequestStatus::SUCCESS, | 644 EXPECT_EQ(net::URLRequestStatus::SUCCESS, |
642 safe_browsing_helper->VerifyTestComplete(server_host, | 645 safe_browsing_helper->VerifyTestComplete(server_host, |
643 server_port, | 646 server_port, |
644 last_step)); | 647 last_step)); |
645 EXPECT_EQ("yes", safe_browsing_helper->response_data()); | 648 EXPECT_EQ("yes", safe_browsing_helper->response_data()); |
646 test_server.Stop(); | 649 test_server.Stop(); |
647 } | 650 } |
OLD | NEW |