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

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

Issue 2146703002: Sample 1% url whitelisted PPAPI downloads to ping safe browsing server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 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
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 "chrome/browser/safe_browsing/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 547
548 548
549 void DownloadProtectionServiceTest::CheckClientDownloadReportCorruptZip( 549 void DownloadProtectionServiceTest::CheckClientDownloadReportCorruptZip(
550 bool is_extended_reporting, 550 bool is_extended_reporting,
551 bool is_incognito) { 551 bool is_incognito) {
552 net::FakeURLFetcherFactory factory(NULL); 552 net::FakeURLFetcherFactory factory(NULL);
553 PrepareResponse( 553 PrepareResponse(
554 &factory, ClientDownloadResponse::SAFE, net::HTTP_OK, 554 &factory, ClientDownloadResponse::SAFE, net::HTTP_OK,
555 net::URLRequestStatus::SUCCESS); 555 net::URLRequestStatus::SUCCESS);
556 556
557 profile_->GetPrefs()->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, 557 SetExtendedReportingPreference(is_extended_reporting);
558 is_extended_reporting);
559 content::MockDownloadItem item; 558 content::MockDownloadItem item;
560 PrepareBasicDownloadItem( 559 PrepareBasicDownloadItem(
561 &item, 560 &item,
562 {"http://www.evil.com/a.zip"}, // url_chain 561 {"http://www.evil.com/a.zip"}, // url_chain
563 "http://www.google.com/", // referrer 562 "http://www.google.com/", // referrer
564 FILE_PATH_LITERAL("a.tmp"), // tmp_path 563 FILE_PATH_LITERAL("a.tmp"), // tmp_path
565 FILE_PATH_LITERAL("a.zip")); // final_path 564 FILE_PATH_LITERAL("a.zip")); // final_path
566 565
567 if (is_incognito) { 566 if (is_incognito) {
568 EXPECT_CALL(item, GetBrowserContext()) 567 EXPECT_CALL(item, GetBrowserContext())
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 EXPECT_EQ(token, DownloadProtectionService::GetDownloadPingToken(&item)); 1970 EXPECT_EQ(token, DownloadProtectionService::GetDownloadPingToken(&item));
1972 1971
1973 DownloadProtectionService::SetDownloadPingToken(&item, std::string()); 1972 DownloadProtectionService::SetDownloadPingToken(&item, std::string());
1974 EXPECT_TRUE(DownloadProtectionService::GetDownloadPingToken(&item).empty()); 1973 EXPECT_TRUE(DownloadProtectionService::GetDownloadPingToken(&item).empty());
1975 } 1974 }
1976 1975
1977 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Unsupported) { 1976 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Unsupported) {
1978 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt")); 1977 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt"));
1979 std::vector<base::FilePath::StringType> alternate_extensions{ 1978 std::vector<base::FilePath::StringType> alternate_extensions{
1980 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".asdfasdf")}; 1979 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".asdfasdf")};
1980 SetExtendedReportingPreference(false);
1981 download_service_->CheckPPAPIDownloadRequest( 1981 download_service_->CheckPPAPIDownloadRequest(
1982 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 1982 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
1983 profile_.get(),
1983 base::Bind(&DownloadProtectionServiceTest::SyncCheckDoneCallback, 1984 base::Bind(&DownloadProtectionServiceTest::SyncCheckDoneCallback,
1984 base::Unretained(this))); 1985 base::Unretained(this)));
1985 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); 1986 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE));
1986 } 1987 }
1987 1988
1988 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedDefault) { 1989 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedDefault) {
1989 net::FakeURLFetcherFactory factory(nullptr); 1990 net::FakeURLFetcherFactory factory(nullptr);
1990 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 1991 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
1991 std::vector<base::FilePath::StringType> alternate_extensions; 1992 std::vector<base::FilePath::StringType> alternate_extensions;
1992 EXPECT_CALL(*sb_service_->mock_database_manager(), 1993 EXPECT_CALL(*sb_service_->mock_database_manager(),
1993 MatchDownloadWhitelistUrl(_)) 1994 MatchDownloadWhitelistUrl(_))
1994 .WillRepeatedly(Return(false)); 1995 .WillRepeatedly(Return(false));
1995 struct { 1996 struct {
1996 ClientDownloadResponse::Verdict verdict; 1997 ClientDownloadResponse::Verdict verdict;
1997 DownloadProtectionService::DownloadCheckResult expected_result; 1998 DownloadProtectionService::DownloadCheckResult expected_result;
1998 } kExpectedResults[] = { 1999 } kExpectedResults[] = {
1999 {ClientDownloadResponse::SAFE, DownloadProtectionService::SAFE}, 2000 {ClientDownloadResponse::SAFE, DownloadProtectionService::SAFE},
2000 {ClientDownloadResponse::DANGEROUS, DownloadProtectionService::DANGEROUS}, 2001 {ClientDownloadResponse::DANGEROUS, DownloadProtectionService::DANGEROUS},
2001 {ClientDownloadResponse::UNCOMMON, DownloadProtectionService::UNCOMMON}, 2002 {ClientDownloadResponse::UNCOMMON, DownloadProtectionService::UNCOMMON},
2002 {ClientDownloadResponse::DANGEROUS_HOST, 2003 {ClientDownloadResponse::DANGEROUS_HOST,
2003 DownloadProtectionService::DANGEROUS_HOST}, 2004 DownloadProtectionService::DANGEROUS_HOST},
2004 {ClientDownloadResponse::POTENTIALLY_UNWANTED, 2005 {ClientDownloadResponse::POTENTIALLY_UNWANTED,
2005 DownloadProtectionService::POTENTIALLY_UNWANTED}, 2006 DownloadProtectionService::POTENTIALLY_UNWANTED},
2006 }; 2007 };
2007 2008
2008 for (const auto& test_case : kExpectedResults) { 2009 for (const auto& test_case : kExpectedResults) {
2009 factory.ClearFakeResponses(); 2010 factory.ClearFakeResponses();
2010 PrepareResponse(&factory, test_case.verdict, net::HTTP_OK, 2011 PrepareResponse(&factory, test_case.verdict, net::HTTP_OK,
2011 net::URLRequestStatus::SUCCESS); 2012 net::URLRequestStatus::SUCCESS);
2013 SetExtendedReportingPreference(false);
2012 download_service_->CheckPPAPIDownloadRequest( 2014 download_service_->CheckPPAPIDownloadRequest(
2013 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2015 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2016 profile_.get(),
2014 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2017 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2015 base::Unretained(this))); 2018 base::Unretained(this)));
2016 MessageLoop::current()->Run(); 2019 MessageLoop::current()->Run();
2017 ASSERT_TRUE(IsResult(test_case.expected_result)); 2020 ASSERT_TRUE(IsResult(test_case.expected_result));
2018 } 2021 }
2019 } 2022 }
2020 2023
2021 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedAlternate) { 2024 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedAlternate) {
2022 net::FakeURLFetcherFactory factory(nullptr); 2025 net::FakeURLFetcherFactory factory(nullptr);
2023 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt")); 2026 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt"));
2024 std::vector<base::FilePath::StringType> alternate_extensions{ 2027 std::vector<base::FilePath::StringType> alternate_extensions{
2025 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".crx")}; 2028 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".crx")};
2026 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, 2029 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
2027 net::URLRequestStatus::SUCCESS); 2030 net::URLRequestStatus::SUCCESS);
2028 EXPECT_CALL(*sb_service_->mock_database_manager(), 2031 EXPECT_CALL(*sb_service_->mock_database_manager(),
2029 MatchDownloadWhitelistUrl(_)) 2032 MatchDownloadWhitelistUrl(_))
2030 .WillRepeatedly(Return(false)); 2033 .WillRepeatedly(Return(false));
2034 SetExtendedReportingPreference(false);
2031 download_service_->CheckPPAPIDownloadRequest( 2035 download_service_->CheckPPAPIDownloadRequest(
2032 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2036 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2037 profile_.get(),
2033 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2038 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2034 base::Unretained(this))); 2039 base::Unretained(this)));
2035 MessageLoop::current()->Run(); 2040 MessageLoop::current()->Run();
2036 2041
2037 ASSERT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2042 ASSERT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2038 } 2043 }
2039 2044
2040 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_WhitelistedURL) { 2045 TEST_F(DownloadProtectionServiceTest,
2046 PPAPIDownloadRequest_WhitelistedURLNotExtendedReporting) {
2041 net::FakeURLFetcherFactory factory(nullptr); 2047 net::FakeURLFetcherFactory factory(nullptr);
2042 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2048 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2043 std::vector<base::FilePath::StringType> alternate_extensions; 2049 std::vector<base::FilePath::StringType> alternate_extensions;
2050 EXPECT_CALL(*sb_service_->mock_database_manager(),
2051 MatchDownloadWhitelistUrl(_))
2052 .WillRepeatedly(Return(true));
2053 SetExtendedReportingPreference(false);
2054 download_service_->CheckPPAPIDownloadRequest(
2055 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2056 profile_.get(),
2057 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2058 base::Unretained(this)));
2059 MessageLoop::current()->Run();
2060
2061 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE));
2062 }
2063
2064 TEST_F(DownloadProtectionServiceTest,
2065 PPAPIDownloadRequest_WhitelistedURLIncognito) {
2066 net::FakeURLFetcherFactory factory(nullptr);
2067 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2068 std::vector<base::FilePath::StringType> alternate_extensions;
2044 EXPECT_CALL(*sb_service_->mock_database_manager(), 2069 EXPECT_CALL(*sb_service_->mock_database_manager(),
2045 MatchDownloadWhitelistUrl(_)) 2070 MatchDownloadWhitelistUrl(_))
2046 .WillRepeatedly(Return(true)); 2071 .WillRepeatedly(Return(true));
2047 download_service_->CheckPPAPIDownloadRequest( 2072 download_service_->CheckPPAPIDownloadRequest(
2048 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2073 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2074 profile_->GetOffTheRecordProfile(),
2049 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2075 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2050 base::Unretained(this))); 2076 base::Unretained(this)));
2051 MessageLoop::current()->Run(); 2077 MessageLoop::current()->Run();
2052 2078
2053 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); 2079 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE));
asanka 2016/07/14 20:44:32 Did you verify that these two tests reliably fail
Jialiu Lin 2016/07/14 21:35:41 Added some code (and comments) to make these test
2054 } 2080 }
2055 2081
2082 TEST_F(DownloadProtectionServiceTest,
2083 PPAPIDownloadRequest_SampleWhitelistedURL) {
2084 net::FakeURLFetcherFactory factory(nullptr);
2085 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2086 std::vector<base::FilePath::StringType> alternate_extensions;
2087 // Configs "server" side response to DANGEROUS.
2088 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
2089 net::URLRequestStatus::SUCCESS);
2090 // Sets the sample rate to 1.00 to trigger ClientDownloadRequest.
2091 SetWhitelistedDownloadSampleRate(1.00);
2092 EXPECT_CALL(*sb_service_->mock_database_manager(),
2093 MatchDownloadWhitelistUrl(_))
2094 .WillRepeatedly(Return(true));
2095 SetExtendedReportingPreference(true);
2096 download_service_->CheckPPAPIDownloadRequest(
2097 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2098 profile_.get(),
2099 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2100 base::Unretained(this)));
2101 MessageLoop::current()->Run();
2102
2103 ASSERT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2104 }
2105
2056 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_FetchFailed) { 2106 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_FetchFailed) {
2057 net::FakeURLFetcherFactory factory(nullptr); 2107 net::FakeURLFetcherFactory factory(nullptr);
2058 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2108 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2059 std::vector<base::FilePath::StringType> alternate_extensions; 2109 std::vector<base::FilePath::StringType> alternate_extensions;
2060 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, 2110 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
2061 net::URLRequestStatus::FAILED); 2111 net::URLRequestStatus::FAILED);
2062 EXPECT_CALL(*sb_service_->mock_database_manager(), 2112 EXPECT_CALL(*sb_service_->mock_database_manager(),
2063 MatchDownloadWhitelistUrl(_)) 2113 MatchDownloadWhitelistUrl(_))
2064 .WillRepeatedly(Return(false)); 2114 .WillRepeatedly(Return(false));
2115 SetExtendedReportingPreference(false);
2065 download_service_->CheckPPAPIDownloadRequest( 2116 download_service_->CheckPPAPIDownloadRequest(
2066 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2117 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2118 profile_.get(),
2067 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2119 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2068 base::Unretained(this))); 2120 base::Unretained(this)));
2069 MessageLoop::current()->Run(); 2121 MessageLoop::current()->Run();
2070 2122
2071 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); 2123 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
2072 } 2124 }
2073 2125
2074 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_InvalidResponse) { 2126 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_InvalidResponse) {
2075 net::FakeURLFetcherFactory factory(nullptr); 2127 net::FakeURLFetcherFactory factory(nullptr);
2076 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2128 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2077 std::vector<base::FilePath::StringType> alternate_extensions; 2129 std::vector<base::FilePath::StringType> alternate_extensions;
2078 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(), 2130 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(),
2079 "Hello world!", net::HTTP_OK, 2131 "Hello world!", net::HTTP_OK,
2080 net::URLRequestStatus::SUCCESS); 2132 net::URLRequestStatus::SUCCESS);
2081 EXPECT_CALL(*sb_service_->mock_database_manager(), 2133 EXPECT_CALL(*sb_service_->mock_database_manager(),
2082 MatchDownloadWhitelistUrl(_)) 2134 MatchDownloadWhitelistUrl(_))
2083 .WillRepeatedly(Return(false)); 2135 .WillRepeatedly(Return(false));
2136 SetExtendedReportingPreference(false);
2084 download_service_->CheckPPAPIDownloadRequest( 2137 download_service_->CheckPPAPIDownloadRequest(
2085 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2138 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2139 profile_.get(),
2086 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2140 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2087 base::Unretained(this))); 2141 base::Unretained(this)));
2088 MessageLoop::current()->Run(); 2142 MessageLoop::current()->Run();
2089 2143
2090 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); 2144 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
2091 } 2145 }
2092 2146
2093 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Timeout) { 2147 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Timeout) {
2094 net::FakeURLFetcherFactory factory(nullptr); 2148 net::FakeURLFetcherFactory factory(nullptr);
2095 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2149 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2096 std::vector<base::FilePath::StringType> alternate_extensions; 2150 std::vector<base::FilePath::StringType> alternate_extensions;
2097 EXPECT_CALL(*sb_service_->mock_database_manager(), 2151 EXPECT_CALL(*sb_service_->mock_database_manager(),
2098 MatchDownloadWhitelistUrl(_)) 2152 MatchDownloadWhitelistUrl(_))
2099 .WillRepeatedly(Return(false)); 2153 .WillRepeatedly(Return(false));
2100 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK, 2154 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK,
2101 net::URLRequestStatus::SUCCESS); 2155 net::URLRequestStatus::SUCCESS);
2102 download_service_->download_request_timeout_ms_ = 0; 2156 download_service_->download_request_timeout_ms_ = 0;
2157 SetExtendedReportingPreference(false);
2103 download_service_->CheckPPAPIDownloadRequest( 2158 download_service_->CheckPPAPIDownloadRequest(
2104 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2159 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2160 profile_.get(),
2105 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2161 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2106 base::Unretained(this))); 2162 base::Unretained(this)));
2107 MessageLoop::current()->Run(); 2163 MessageLoop::current()->Run();
2108 2164
2109 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); 2165 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
2110 } 2166 }
2111 2167
2112 namespace { 2168 namespace {
2113 2169
2114 std::unique_ptr<net::FakeURLFetcher> FakeURLFetcherCreatorFunc( 2170 std::unique_ptr<net::FakeURLFetcher> FakeURLFetcherCreatorFunc(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2153 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2209 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2154 std::vector<base::FilePath::StringType> alternate_extensions{ 2210 std::vector<base::FilePath::StringType> alternate_extensions{
2155 FILE_PATH_LITERAL(".txt"), FILE_PATH_LITERAL(".abc"), 2211 FILE_PATH_LITERAL(".txt"), FILE_PATH_LITERAL(".abc"),
2156 FILE_PATH_LITERAL(""), FILE_PATH_LITERAL(".sdF")}; 2212 FILE_PATH_LITERAL(""), FILE_PATH_LITERAL(".sdF")};
2157 EXPECT_CALL(*sb_service_->mock_database_manager(), 2213 EXPECT_CALL(*sb_service_->mock_database_manager(),
2158 MatchDownloadWhitelistUrl(_)) 2214 MatchDownloadWhitelistUrl(_))
2159 .WillRepeatedly(Return(false)); 2215 .WillRepeatedly(Return(false));
2160 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK, 2216 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK,
2161 net::URLRequestStatus::SUCCESS); 2217 net::URLRequestStatus::SUCCESS);
2162 const GURL kRequestorUrl("http://example.com/foo"); 2218 const GURL kRequestorUrl("http://example.com/foo");
2219 SetExtendedReportingPreference(false);
2163 download_service_->CheckPPAPIDownloadRequest( 2220 download_service_->CheckPPAPIDownloadRequest(
2164 kRequestorUrl, default_file_path, alternate_extensions, 2221 kRequestorUrl, default_file_path, alternate_extensions, profile_.get(),
2165 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2222 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2166 base::Unretained(this))); 2223 base::Unretained(this)));
2167 MessageLoop::current()->Run(); 2224 MessageLoop::current()->Run();
2168 2225
2169 ASSERT_FALSE(upload_data.empty()); 2226 ASSERT_FALSE(upload_data.empty());
2170 2227
2171 ClientDownloadRequest request; 2228 ClientDownloadRequest request;
2172 ASSERT_TRUE(request.ParseFromString(upload_data)); 2229 ASSERT_TRUE(request.ParseFromString(upload_data));
2173 2230
2174 EXPECT_EQ(ClientDownloadRequest::PPAPI_SAVE_REQUEST, request.download_type()); 2231 EXPECT_EQ(ClientDownloadRequest::PPAPI_SAVE_REQUEST, request.download_type());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2312 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2256 base::Unretained(this))); 2313 base::Unretained(this)));
2257 MessageLoop::current()->Run(); 2314 MessageLoop::current()->Run();
2258 2315
2259 EXPECT_FALSE(HasClientDownloadRequest()); 2316 EXPECT_FALSE(HasClientDownloadRequest());
2260 // Overriden by flag: 2317 // Overriden by flag:
2261 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2318 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2262 } 2319 }
2263 2320
2264 } // namespace safe_browsing 2321 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698