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

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

Issue 10581012: Move test_url_fetcher_factory.* from content/ to net/url_request (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove export annotations 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 #include <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 15 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
16 #include "chrome/common/safe_browsing/client_model.pb.h" 16 #include "chrome/common/safe_browsing/client_model.pb.h"
17 #include "chrome/common/safe_browsing/csd.pb.h" 17 #include "chrome/common/safe_browsing/csd.pb.h"
18 #include "content/public/test/test_browser_thread.h" 18 #include "content/public/test/test_browser_thread.h"
19 #include "content/public/test/test_url_fetcher_factory.h"
20 #include "crypto/sha2.h" 19 #include "crypto/sha2.h"
21 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "net/url_request/test_url_fetcher_factory.h"
22 #include "net/url_request/url_request_status.h" 22 #include "net/url_request/url_request_status.h"
23 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 25
26 using ::testing::_; 26 using ::testing::_;
27 using ::testing::Invoke; 27 using ::testing::Invoke;
28 using ::testing::Mock; 28 using ::testing::Mock;
29 using ::testing::StrictMock; 29 using ::testing::StrictMock;
30 using content::BrowserThread; 30 using content::BrowserThread;
31 31
(...skipping 26 matching lines...) Expand all
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 class ClientSideDetectionServiceTest : public testing::Test { 62 class ClientSideDetectionServiceTest : public testing::Test {
63 protected: 63 protected:
64 virtual void SetUp() { 64 virtual void SetUp() {
65 file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE, 65 file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE,
66 &msg_loop_)); 66 &msg_loop_));
67 67
68 factory_.reset(new FakeURLFetcherFactory()); 68 factory_.reset(new net::FakeURLFetcherFactory());
69 69
70 browser_thread_.reset(new content::TestBrowserThread(BrowserThread::UI, 70 browser_thread_.reset(new content::TestBrowserThread(BrowserThread::UI,
71 &msg_loop_)); 71 &msg_loop_));
72 } 72 }
73 73
74 virtual void TearDown() { 74 virtual void TearDown() {
75 msg_loop_.RunAllPending(); 75 msg_loop_.RunAllPending();
76 csd_service_.reset(); 76 csd_service_.reset();
77 file_thread_.reset(); 77 file_thread_.reset();
78 browser_thread_.reset(); 78 browser_thread_.reset();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void AddNonModelFeature(const std::string& name, double value, 183 void AddNonModelFeature(const std::string& name, double value,
184 ClientPhishingRequest* request) { 184 ClientPhishingRequest* request) {
185 ClientPhishingRequest_Feature* feature = 185 ClientPhishingRequest_Feature* feature =
186 request->add_non_model_feature_map(); 186 request->add_non_model_feature_map();
187 feature->set_name(name); 187 feature->set_name(name);
188 feature->set_value(value); 188 feature->set_value(value);
189 } 189 }
190 190
191 protected: 191 protected:
192 scoped_ptr<ClientSideDetectionService> csd_service_; 192 scoped_ptr<ClientSideDetectionService> csd_service_;
193 scoped_ptr<FakeURLFetcherFactory> factory_; 193 scoped_ptr<net::FakeURLFetcherFactory> factory_;
194 MessageLoop msg_loop_; 194 MessageLoop msg_loop_;
195 195
196 private: 196 private:
197 void SendRequestDone(GURL phishing_url, bool is_phishing) { 197 void SendRequestDone(GURL phishing_url, bool is_phishing) {
198 ASSERT_EQ(phishing_url, phishing_url_); 198 ASSERT_EQ(phishing_url, phishing_url_);
199 is_phishing_ = is_phishing; 199 is_phishing_ = is_phishing;
200 msg_loop_.Quit(); 200 msg_loop_.Quit();
201 } 201 }
202 202
203 scoped_ptr<content::TestBrowserThread> browser_thread_; 203 scoped_ptr<content::TestBrowserThread> browser_thread_;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 EXPECT_CALL(*service, ScheduleFetchModel(_)) 656 EXPECT_CALL(*service, ScheduleFetchModel(_))
657 .WillOnce(Invoke(service, &MockClientSideDetectionService::Schedule)); 657 .WillOnce(Invoke(service, &MockClientSideDetectionService::Schedule));
658 EXPECT_CALL(*service, EndFetchModel( 658 EXPECT_CALL(*service, EndFetchModel(
659 ClientSideDetectionService::MODEL_NOT_CHANGED)) 659 ClientSideDetectionService::MODEL_NOT_CHANGED))
660 .WillOnce(Invoke(service, &MockClientSideDetectionService::Disable)); 660 .WillOnce(Invoke(service, &MockClientSideDetectionService::Disable));
661 csd_service_->SetEnabledAndRefreshState(true); 661 csd_service_->SetEnabledAndRefreshState(true);
662 EXPECT_FALSE(SendClientReportPhishingRequest(GURL("http://a.com/"), 0.4f)); 662 EXPECT_FALSE(SendClientReportPhishingRequest(GURL("http://a.com/"), 0.4f));
663 Mock::VerifyAndClearExpectations(service); 663 Mock::VerifyAndClearExpectations(service);
664 } 664 }
665 } // namespace safe_browsing 665 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698