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

Side by Side Diff: chrome/browser/download/download_safe_browsing_client_unittest.cc

Issue 7134017: Make safe browsing work in a multi-profile environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: addressed sky's nit Created 9 years, 5 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) 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 "content/browser/browser_thread.h" 8 #include "content/browser/browser_thread.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 EXPECT_CALL(*sb_service.get(), 52 EXPECT_CALL(*sb_service.get(),
53 ReportSafeBrowsingHit(GURL(kUrl3), GURL(kUrl1), GURL(kRefUrl), true, 53 ReportSafeBrowsingHit(GURL(kUrl3), GURL(kUrl1), GURL(kRefUrl), true,
54 SafeBrowsingService::BINARY_MALWARE_URL, 54 SafeBrowsingService::BINARY_MALWARE_URL,
55 expected_post)); 55 expected_post));
56 std::vector<GURL> url_chain; 56 std::vector<GURL> url_chain;
57 url_chain.push_back(GURL(kUrl1)); 57 url_chain.push_back(GURL(kUrl1));
58 url_chain.push_back(GURL(kUrl2)); 58 url_chain.push_back(GURL(kUrl2));
59 url_chain.push_back(GURL(kUrl3)); 59 url_chain.push_back(GURL(kUrl3));
60 60
61 scoped_refptr<DownloadSBClient> client( 61 scoped_refptr<DownloadSBClient> client(
62 new DownloadSBClient(1, url_chain, GURL(kRefUrl))); 62 new DownloadSBClient(1, url_chain, GURL(kRefUrl), true));
63 client->SetSBService(sb_service.get()); 63 client->SetSBService(sb_service.get());
64 64
65 client->ReportMalware(SafeBrowsingService::BINARY_MALWARE_URL, ""); 65 client->ReportMalware(SafeBrowsingService::BINARY_MALWARE_URL, "");
66 } 66 }
67 67
68 TEST_F(DownloadSBClientTest, DigestHit) { 68 TEST_F(DownloadSBClientTest, DigestHit) {
69 std::string hash_data = "\xDE\xAD\xBE\xEF"; 69 std::string hash_data = "\xDE\xAD\xBE\xEF";
70 std::string hash_string = "DEADBEEF"; 70 std::string hash_string = "DEADBEEF";
71 std::string expected_post = 71 std::string expected_post =
72 hash_string + "\n" + kUrl1 + "\n" + kUrl2 + "\n" + kUrl3 + "\n"; 72 hash_string + "\n" + kUrl1 + "\n" + kUrl2 + "\n" + kUrl3 + "\n";
73 scoped_refptr<MockSafeBrowsingService> sb_service( 73 scoped_refptr<MockSafeBrowsingService> sb_service(
74 new MockSafeBrowsingService); 74 new MockSafeBrowsingService);
75 EXPECT_CALL(*sb_service.get(), 75 EXPECT_CALL(*sb_service.get(),
76 ReportSafeBrowsingHit(GURL(kUrl3), GURL(kUrl1), GURL(kRefUrl), true, 76 ReportSafeBrowsingHit(GURL(kUrl3), GURL(kUrl1), GURL(kRefUrl), true,
77 SafeBrowsingService::BINARY_MALWARE_HASH, 77 SafeBrowsingService::BINARY_MALWARE_HASH,
78 expected_post)); 78 expected_post));
79 std::vector<GURL> url_chain; 79 std::vector<GURL> url_chain;
80 url_chain.push_back(GURL(kUrl1)); 80 url_chain.push_back(GURL(kUrl1));
81 url_chain.push_back(GURL(kUrl2)); 81 url_chain.push_back(GURL(kUrl2));
82 url_chain.push_back(GURL(kUrl3)); 82 url_chain.push_back(GURL(kUrl3));
83 83
84 scoped_refptr<DownloadSBClient> client( 84 scoped_refptr<DownloadSBClient> client(
85 new DownloadSBClient(1, url_chain, GURL(kRefUrl))); 85 new DownloadSBClient(1, url_chain, GURL(kRefUrl), true));
86 client->SetSBService(sb_service.get()); 86 client->SetSBService(sb_service.get());
87 87
88 client->ReportMalware(SafeBrowsingService::BINARY_MALWARE_HASH, hash_data); 88 client->ReportMalware(SafeBrowsingService::BINARY_MALWARE_HASH, hash_data);
89 } 89 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_safe_browsing_client.cc ('k') | chrome/browser/profiles/off_the_record_profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698