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 #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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 void Disable(int) { | 47 void Disable(int) { |
48 // Ignore the status. | 48 // Ignore the status. |
49 SetEnabledAndRefreshState(false); | 49 SetEnabledAndRefreshState(false); |
50 } | 50 } |
51 | 51 |
52 private: | 52 private: |
53 DISALLOW_COPY_AND_ASSIGN(MockClientSideDetectionService); | 53 DISALLOW_COPY_AND_ASSIGN(MockClientSideDetectionService); |
54 }; | 54 }; |
55 | 55 |
56 ACTION(QuitCurrentMessageLoop) { | 56 ACTION(QuitCurrentMessageLoop) { |
57 MessageLoop::current()->Quit(); | 57 base::MessageLoop::current()->Quit(); |
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 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 ClientPhishingRequest* request) { | 209 ClientPhishingRequest* request) { |
210 ClientPhishingRequest_Feature* feature = | 210 ClientPhishingRequest_Feature* feature = |
211 request->add_non_model_feature_map(); | 211 request->add_non_model_feature_map(); |
212 feature->set_name(name); | 212 feature->set_name(name); |
213 feature->set_value(value); | 213 feature->set_value(value); |
214 } | 214 } |
215 | 215 |
216 protected: | 216 protected: |
217 scoped_ptr<ClientSideDetectionService> csd_service_; | 217 scoped_ptr<ClientSideDetectionService> csd_service_; |
218 scoped_ptr<net::FakeURLFetcherFactory> factory_; | 218 scoped_ptr<net::FakeURLFetcherFactory> factory_; |
219 MessageLoop msg_loop_; | 219 base::MessageLoop msg_loop_; |
220 | 220 |
221 private: | 221 private: |
222 void SendRequestDone(GURL phishing_url, bool is_phishing) { | 222 void SendRequestDone(GURL phishing_url, bool is_phishing) { |
223 ASSERT_EQ(phishing_url, phishing_url_); | 223 ASSERT_EQ(phishing_url, phishing_url_); |
224 is_phishing_ = is_phishing; | 224 is_phishing_ = is_phishing; |
225 msg_loop_.Quit(); | 225 msg_loop_.Quit(); |
226 } | 226 } |
227 | 227 |
228 void SendMalwareRequestDone(GURL url, bool is_malware) { | 228 void SendMalwareRequestDone(GURL url, bool is_malware) { |
229 ASSERT_EQ(phishing_url_, url); | 229 ASSERT_EQ(phishing_url_, url); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 EXPECT_CALL(*service, ScheduleFetchModel(_)) | 735 EXPECT_CALL(*service, ScheduleFetchModel(_)) |
736 .WillOnce(Invoke(service, &MockClientSideDetectionService::Schedule)); | 736 .WillOnce(Invoke(service, &MockClientSideDetectionService::Schedule)); |
737 EXPECT_CALL(*service, EndFetchModel( | 737 EXPECT_CALL(*service, EndFetchModel( |
738 ClientSideDetectionService::MODEL_NOT_CHANGED)) | 738 ClientSideDetectionService::MODEL_NOT_CHANGED)) |
739 .WillOnce(Invoke(service, &MockClientSideDetectionService::Disable)); | 739 .WillOnce(Invoke(service, &MockClientSideDetectionService::Disable)); |
740 csd_service_->SetEnabledAndRefreshState(true); | 740 csd_service_->SetEnabledAndRefreshState(true); |
741 EXPECT_FALSE(SendClientReportPhishingRequest(GURL("http://a.com/"), 0.4f)); | 741 EXPECT_FALSE(SendClientReportPhishingRequest(GURL("http://a.com/"), 0.4f)); |
742 Mock::VerifyAndClearExpectations(service); | 742 Mock::VerifyAndClearExpectations(service); |
743 } | 743 } |
744 } // namespace safe_browsing | 744 } // namespace safe_browsing |
OLD | NEW |