| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/browser_process.h" | 32 #include "chrome/browser/browser_process.h" |
| 33 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
| 34 #include "chrome/browser/safe_browsing/protocol_manager.h" | 34 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 35 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 35 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 36 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
| 37 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 38 #include "chrome/test/base/in_process_browser_test.h" | 38 #include "chrome/test/base/in_process_browser_test.h" |
| 39 #include "chrome/test/base/ui_test_utils.h" | 39 #include "chrome/test/base/ui_test_utils.h" |
| 40 #include "content/browser/browser_thread.h" | 40 #include "content/browser/browser_thread.h" |
| 41 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 41 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 42 #include "content/common/net/url_fetcher.h" | 42 #include "content/public/common/url_fetcher.h" |
| 43 #include "content/public/common/url_fetcher_delegate.h" | 43 #include "content/public/common/url_fetcher_delegate.h" |
| 44 #include "net/base/host_resolver.h" | 44 #include "net/base/host_resolver.h" |
| 45 #include "net/base/load_flags.h" | 45 #include "net/base/load_flags.h" |
| 46 #include "net/base/net_log.h" | 46 #include "net/base/net_log.h" |
| 47 #include "net/test/python_utils.h" | 47 #include "net/test/python_utils.h" |
| 48 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
| 49 | 49 |
| 50 namespace { | 50 namespace { |
| 51 | 51 |
| 52 const FilePath::CharType kDataFile[] = FILE_PATH_LITERAL("testing_input.dat"); | 52 const FilePath::CharType kDataFile[] = FILE_PATH_LITERAL("testing_input.dat"); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 private: | 522 private: |
| 523 // Stops UI loop after desired status is updated. | 523 // Stops UI loop after desired status is updated. |
| 524 void StopUILoop() { | 524 void StopUILoop() { |
| 525 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 525 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 526 MessageLoopForUI::current()->Quit(); | 526 MessageLoopForUI::current()->Quit(); |
| 527 } | 527 } |
| 528 | 528 |
| 529 // Fetch a URL. If message_loop_started is true, starts the message loop | 529 // Fetch a URL. If message_loop_started is true, starts the message loop |
| 530 // so the caller could wait till OnURLFetchComplete is called. | 530 // so the caller could wait till OnURLFetchComplete is called. |
| 531 net::URLRequestStatus::Status FetchUrl(const GURL& url) { | 531 net::URLRequestStatus::Status FetchUrl(const GURL& url) { |
| 532 url_fetcher_.reset(new URLFetcher(url, URLFetcher::GET, this)); | 532 url_fetcher_.reset(content::URLFetcher::Create( |
| 533 url, content::URLFetcher::GET, this)); |
| 533 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 534 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
| 534 url_fetcher_->SetRequestContext( | 535 url_fetcher_->SetRequestContext( |
| 535 Profile::Deprecated::GetDefaultRequestContext()); | 536 Profile::Deprecated::GetDefaultRequestContext()); |
| 536 url_fetcher_->Start(); | 537 url_fetcher_->Start(); |
| 537 ui_test_utils::RunMessageLoop(); | 538 ui_test_utils::RunMessageLoop(); |
| 538 return response_status_; | 539 return response_status_; |
| 539 } | 540 } |
| 540 | 541 |
| 541 base::OneShotTimer<SafeBrowsingServiceTestHelper> check_update_timer_; | 542 base::OneShotTimer<SafeBrowsingServiceTestHelper> check_update_timer_; |
| 542 SafeBrowsingServiceTest* safe_browsing_test_; | 543 SafeBrowsingServiceTest* safe_browsing_test_; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 } | 649 } |
| 649 | 650 |
| 650 // Verifies with server if test is done and waits till server responses. | 651 // Verifies with server if test is done and waits till server responses. |
| 651 EXPECT_EQ(net::URLRequestStatus::SUCCESS, | 652 EXPECT_EQ(net::URLRequestStatus::SUCCESS, |
| 652 safe_browsing_helper->VerifyTestComplete(server_host, | 653 safe_browsing_helper->VerifyTestComplete(server_host, |
| 653 server_port, | 654 server_port, |
| 654 last_step)); | 655 last_step)); |
| 655 EXPECT_EQ("yes", safe_browsing_helper->response_data()); | 656 EXPECT_EQ("yes", safe_browsing_helper->response_data()); |
| 656 test_server.Stop(); | 657 test_server.Stop(); |
| 657 } | 658 } |
| OLD | NEW |