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 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "chrome/browser/download/download_safe_browsing_client.h" | 6 #include "chrome/browser/download/download_safe_browsing_client.h" |
7 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 7 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
8 #include "chrome/test/base/testing_browser_process_test.h" | |
9 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
12 | 11 |
13 namespace { | 12 namespace { |
14 | 13 |
15 const char* kUrl1 = "http://127.0.0.1/"; | 14 const char* kUrl1 = "http://127.0.0.1/"; |
16 const char* kUrl2 = "http://127.0.0.1/two"; | 15 const char* kUrl2 = "http://127.0.0.1/two"; |
17 const char* kUrl3 = "http://127.0.0.1/three"; | 16 const char* kUrl3 = "http://127.0.0.1/three"; |
18 const char* kRefUrl = "http://127.0.0.1/referrer"; | 17 const char* kRefUrl = "http://127.0.0.1/referrer"; |
19 | 18 |
20 class MockSafeBrowsingService : public SafeBrowsingService { | 19 class MockSafeBrowsingService : public SafeBrowsingService { |
21 public: | 20 public: |
22 MockSafeBrowsingService() {} | 21 MockSafeBrowsingService() {} |
23 virtual ~MockSafeBrowsingService() {} | 22 virtual ~MockSafeBrowsingService() {} |
24 | 23 |
25 MOCK_METHOD6(ReportSafeBrowsingHit, | 24 MOCK_METHOD6(ReportSafeBrowsingHit, |
26 void(const GURL&, const GURL&, const GURL&, bool, UrlCheckResult, | 25 void(const GURL&, const GURL&, const GURL&, bool, UrlCheckResult, |
27 const std::string&)); | 26 const std::string&)); |
28 | 27 |
29 private: | 28 private: |
30 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingService); | 29 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingService); |
31 }; | 30 }; |
32 | 31 |
33 } // namespace | 32 } // namespace |
34 | 33 |
35 class DownloadSBClientTest : public TestingBrowserProcessTest { | 34 class DownloadSBClientTest : public testing::Test { |
36 public: | 35 public: |
37 DownloadSBClientTest() : | 36 DownloadSBClientTest() : |
38 ui_thread_(BrowserThread::UI, &loop_) { | 37 ui_thread_(BrowserThread::UI, &loop_) { |
39 } | 38 } |
40 | 39 |
41 private: | 40 private: |
42 MessageLoop loop_; | 41 MessageLoop loop_; |
43 | 42 |
44 // UI thread to satisfy debug checks in DownloadSBClient. | 43 // UI thread to satisfy debug checks in DownloadSBClient. |
45 BrowserThread ui_thread_; | 44 BrowserThread ui_thread_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 url_chain.push_back(GURL(kUrl1)); | 80 url_chain.push_back(GURL(kUrl1)); |
82 url_chain.push_back(GURL(kUrl2)); | 81 url_chain.push_back(GURL(kUrl2)); |
83 url_chain.push_back(GURL(kUrl3)); | 82 url_chain.push_back(GURL(kUrl3)); |
84 | 83 |
85 scoped_refptr<DownloadSBClient> client( | 84 scoped_refptr<DownloadSBClient> client( |
86 new DownloadSBClient(1, url_chain, GURL(kRefUrl), true)); | 85 new DownloadSBClient(1, url_chain, GURL(kRefUrl), true)); |
87 client->SetSBService(sb_service.get()); | 86 client->SetSBService(sb_service.get()); |
88 | 87 |
89 client->ReportMalware(SafeBrowsingService::BINARY_MALWARE_HASH, hash_data); | 88 client->ReportMalware(SafeBrowsingService::BINARY_MALWARE_HASH, hash_data); |
90 } | 89 } |
OLD | NEW |