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

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

Issue 10554008: Move content::URLFetcher static functions to net::URLFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win link error Created 8 years, 6 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
OLDNEW
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 20 matching lines...) Expand all
31 #include "base/time.h" 31 #include "base/time.h"
32 #include "base/utf_string_conversions.h" 32 #include "base/utf_string_conversions.h"
33 #include "chrome/browser/browser_process.h" 33 #include "chrome/browser/browser_process.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/public/browser/browser_context.h" 40 #include "content/public/browser/browser_context.h"
41 #include "content/public/common/url_fetcher.h"
42 #include "content/public/test/test_browser_thread.h" 41 #include "content/public/test/test_browser_thread.h"
43 #include "net/base/host_resolver.h" 42 #include "net/base/host_resolver.h"
44 #include "net/base/load_flags.h" 43 #include "net/base/load_flags.h"
45 #include "net/base/net_log.h" 44 #include "net/base/net_log.h"
46 #include "net/test/python_utils.h" 45 #include "net/test/python_utils.h"
46 #include "net/url_request/url_fetcher.h"
47 #include "net/url_request/url_fetcher_delegate.h" 47 #include "net/url_request/url_fetcher_delegate.h"
48 #include "net/url_request/url_request_status.h" 48 #include "net/url_request/url_request_status.h"
49 #include "testing/gtest/include/gtest/gtest.h" 49 #include "testing/gtest/include/gtest/gtest.h"
50 50
51 using content::BrowserThread; 51 using content::BrowserThread;
52 52
53 namespace { 53 namespace {
54 54
55 const FilePath::CharType kDataFile[] = 55 const FilePath::CharType kDataFile[] =
56 FILE_PATH_LITERAL("testing_input_nomac.dat"); 56 FILE_PATH_LITERAL("testing_input_nomac.dat");
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 521
522 // Stops UI loop after desired status is updated. 522 // Stops UI loop after desired status is updated.
523 void StopUILoop() { 523 void StopUILoop() {
524 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 524 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
525 MessageLoopForUI::current()->Quit(); 525 MessageLoopForUI::current()->Quit();
526 } 526 }
527 527
528 // Fetch a URL. If message_loop_started is true, starts the message loop 528 // Fetch a URL. If message_loop_started is true, starts the message loop
529 // so the caller could wait till OnURLFetchComplete is called. 529 // so the caller could wait till OnURLFetchComplete is called.
530 net::URLRequestStatus::Status FetchUrl(const GURL& url) { 530 net::URLRequestStatus::Status FetchUrl(const GURL& url) {
531 url_fetcher_.reset(content::URLFetcher::Create( 531 url_fetcher_.reset(net::URLFetcher::Create(
532 url, net::URLFetcher::GET, this)); 532 url, net::URLFetcher::GET, this));
533 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); 533 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
534 url_fetcher_->SetRequestContext(request_context_); 534 url_fetcher_->SetRequestContext(request_context_);
535 url_fetcher_->Start(); 535 url_fetcher_->Start();
536 ui_test_utils::RunMessageLoop(); 536 ui_test_utils::RunMessageLoop();
537 return response_status_; 537 return response_status_;
538 } 538 }
539 539
540 base::OneShotTimer<SafeBrowsingServiceTestHelper> check_update_timer_; 540 base::OneShotTimer<SafeBrowsingServiceTestHelper> check_update_timer_;
541 SafeBrowsingServiceTest* safe_browsing_test_; 541 SafeBrowsingServiceTest* safe_browsing_test_;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 } 644 }
645 645
646 // Verifies with server if test is done and waits till server responses. 646 // Verifies with server if test is done and waits till server responses.
647 EXPECT_EQ(net::URLRequestStatus::SUCCESS, 647 EXPECT_EQ(net::URLRequestStatus::SUCCESS,
648 safe_browsing_helper->VerifyTestComplete(server_host, 648 safe_browsing_helper->VerifyTestComplete(server_host,
649 server_port, 649 server_port,
650 last_step)); 650 last_step));
651 EXPECT_EQ("yes", safe_browsing_helper->response_data()); 651 EXPECT_EQ("yes", safe_browsing_helper->response_data());
652 test_server.Stop(); 652 test_server.Stop();
653 } 653 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager.cc ('k') | chrome/browser/search_engines/template_url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698