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

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

Issue 1548133002: Switch to standard integer types in chrome/browser/, part 3 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_feedback_service.h" 5 #include "chrome/browser/safe_browsing/download_feedback_service.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <vector> 10 #include <vector>
8 11
9 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
11 #include "base/run_loop.h" 14 #include "base/run_loop.h"
12 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
13 #include "chrome/browser/safe_browsing/download_feedback.h" 16 #include "chrome/browser/safe_browsing/download_feedback.h"
14 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
15 #include "content/public/test/mock_download_item.h" 18 #include "content/public/test/mock_download_item.h"
16 #include "content/public/test/test_browser_thread_bundle.h" 19 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 111
109 size_t num_feedbacks() const { 112 size_t num_feedbacks() const {
110 return feedbacks_.size(); 113 return feedbacks_.size();
111 } 114 }
112 115
113 private: 116 private:
114 std::vector<FakeDownloadFeedback*> feedbacks_; 117 std::vector<FakeDownloadFeedback*> feedbacks_;
115 }; 118 };
116 119
117 bool WillStorePings(DownloadProtectionService::DownloadCheckResult result, 120 bool WillStorePings(DownloadProtectionService::DownloadCheckResult result,
118 int64 size) { 121 int64_t size) {
119 content::MockDownloadItem item; 122 content::MockDownloadItem item;
120 EXPECT_CALL(item, GetReceivedBytes()).WillRepeatedly(Return(size)); 123 EXPECT_CALL(item, GetReceivedBytes()).WillRepeatedly(Return(size));
121 124
122 EXPECT_FALSE(DownloadFeedbackService::IsEnabledForDownload(item)); 125 EXPECT_FALSE(DownloadFeedbackService::IsEnabledForDownload(item));
123 DownloadFeedbackService::MaybeStorePingsForDownload(result, &item, "a", "b"); 126 DownloadFeedbackService::MaybeStorePingsForDownload(result, &item, "a", "b");
124 return DownloadFeedbackService::IsEnabledForDownload(item); 127 return DownloadFeedbackService::IsEnabledForDownload(item);
125 } 128 }
126 129
127 } // namespace 130 } // namespace
128 131
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 protected: 168 protected:
166 base::ScopedTempDir temp_dir_; 169 base::ScopedTempDir temp_dir_;
167 content::TestBrowserThreadBundle thread_bundle_; 170 content::TestBrowserThreadBundle thread_bundle_;
168 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 171 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
169 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 172 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
170 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; 173 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
171 FakeDownloadFeedbackFactory download_feedback_factory_; 174 FakeDownloadFeedbackFactory download_feedback_factory_;
172 }; 175 };
173 176
174 TEST_F(DownloadFeedbackServiceTest, MaybeStorePingsForDownload) { 177 TEST_F(DownloadFeedbackServiceTest, MaybeStorePingsForDownload) {
175 const int64 ok_size = DownloadFeedback::kMaxUploadSize; 178 const int64_t ok_size = DownloadFeedback::kMaxUploadSize;
176 const int64 bad_size = DownloadFeedback::kMaxUploadSize + 1; 179 const int64_t bad_size = DownloadFeedback::kMaxUploadSize + 1;
177 180
178 EXPECT_FALSE(WillStorePings(DownloadProtectionService::SAFE, ok_size)); 181 EXPECT_FALSE(WillStorePings(DownloadProtectionService::SAFE, ok_size));
179 EXPECT_FALSE(WillStorePings(DownloadProtectionService::DANGEROUS, ok_size)); 182 EXPECT_FALSE(WillStorePings(DownloadProtectionService::DANGEROUS, ok_size));
180 EXPECT_TRUE(WillStorePings(DownloadProtectionService::UNCOMMON, ok_size)); 183 EXPECT_TRUE(WillStorePings(DownloadProtectionService::UNCOMMON, ok_size));
181 EXPECT_TRUE( 184 EXPECT_TRUE(
182 WillStorePings(DownloadProtectionService::DANGEROUS_HOST, ok_size)); 185 WillStorePings(DownloadProtectionService::DANGEROUS_HOST, ok_size));
183 EXPECT_TRUE( 186 EXPECT_TRUE(
184 WillStorePings(DownloadProtectionService::POTENTIALLY_UNWANTED, ok_size)); 187 WillStorePings(DownloadProtectionService::POTENTIALLY_UNWANTED, ok_size));
185 188
186 EXPECT_FALSE(WillStorePings(DownloadProtectionService::SAFE, bad_size)); 189 EXPECT_FALSE(WillStorePings(DownloadProtectionService::SAFE, bad_size));
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // was deleted. 369 // was deleted.
367 EXPECT_FALSE(base::PathExists(file_path[2])); 370 EXPECT_FALSE(base::PathExists(file_path[2]));
368 371
369 // These files should still exist since the FakeDownloadFeedback does not 372 // These files should still exist since the FakeDownloadFeedback does not
370 // delete them. 373 // delete them.
371 EXPECT_TRUE(base::PathExists(file_path[0])); 374 EXPECT_TRUE(base::PathExists(file_path[0]));
372 EXPECT_TRUE(base::PathExists(file_path[1])); 375 EXPECT_TRUE(base::PathExists(file_path[1]));
373 } 376 }
374 377
375 } // namespace safe_browsing 378 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/download_feedback_service.h ('k') | chrome/browser/safe_browsing/download_protection_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698