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

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

Issue 2029903002: Add token field to ClientSafeBrowsingReportReqeust (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit in test Created 4 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
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 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 StrictMock<content::MockDownloadItem> mock_download_item; 1846 StrictMock<content::MockDownloadItem> mock_download_item;
1847 1847
1848 EXPECT_CALL(mock_download_item, GetDangerType()) 1848 EXPECT_CALL(mock_download_item, GetDangerType())
1849 .WillOnce(Return(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST)); 1849 .WillOnce(Return(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST));
1850 EXPECT_CALL(mock_page_navigator, OpenURL(OpenURLParamsWithContextValue("7"))); 1850 EXPECT_CALL(mock_page_navigator, OpenURL(OpenURLParamsWithContextValue("7")));
1851 1851
1852 download_service_->ShowDetailsForDownload(mock_download_item, 1852 download_service_->ShowDetailsForDownload(mock_download_item,
1853 &mock_page_navigator); 1853 &mock_page_navigator);
1854 } 1854 }
1855 1855
1856 TEST_F(DownloadProtectionServiceTest, GetAndSetDownloadPingToken) {
1857 content::MockDownloadItem item;
1858 EXPECT_TRUE(DownloadProtectionService::GetDownloadPingToken(&item).empty());
1859 std::string token = "download_ping_token";
1860 DownloadProtectionService::SetDownloadPingToken(&item, token);
1861 EXPECT_EQ(token, DownloadProtectionService::GetDownloadPingToken(&item));
1862
1863 DownloadProtectionService::SetDownloadPingToken(&item, std::string());
1864 EXPECT_TRUE(DownloadProtectionService::GetDownloadPingToken(&item).empty());
1865 }
1866
1856 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Unsupported) { 1867 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Unsupported) {
1857 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt")); 1868 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt"));
1858 std::vector<base::FilePath::StringType> alternate_extensions{ 1869 std::vector<base::FilePath::StringType> alternate_extensions{
1859 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".asdfasdf")}; 1870 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".asdfasdf")};
1860 download_service_->CheckPPAPIDownloadRequest( 1871 download_service_->CheckPPAPIDownloadRequest(
1861 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 1872 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
1862 base::Bind(&DownloadProtectionServiceTest::SyncCheckDoneCallback, 1873 base::Bind(&DownloadProtectionServiceTest::SyncCheckDoneCallback,
1863 base::Unretained(this))); 1874 base::Unretained(this)));
1864 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); 1875 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE));
1865 } 1876 }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2145 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2135 base::Unretained(this))); 2146 base::Unretained(this)));
2136 MessageLoop::current()->Run(); 2147 MessageLoop::current()->Run();
2137 2148
2138 EXPECT_FALSE(HasClientDownloadRequest()); 2149 EXPECT_FALSE(HasClientDownloadRequest());
2139 // Overriden by flag: 2150 // Overriden by flag:
2140 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2151 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2141 } 2152 }
2142 2153
2143 } // namespace safe_browsing 2154 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698