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

Unified Diff: chrome/browser/safe_browsing/download_protection_service_unittest.cc

Issue 179963002: New Zip::ZipFromMemory API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup! New Zip::ZipFromMemory API. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/download_protection_service_unittest.cc
diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
index 34bcf1a3ddabff50b99c62c28f89cf9e0eda97af..448eb5457bc58a9b21c07b5a49168fde051dd5f2 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -13,7 +13,7 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/memory/ref_counted.h"
+#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
@@ -707,13 +707,10 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadZip) {
// Write out a zip archive to the temporary file. In this case, it
// only contains a text file.
- base::ScopedTempDir zip_source_dir;
- ASSERT_TRUE(zip_source_dir.CreateUniqueTempDir());
- std::string file_contents = "dummy file";
- ASSERT_EQ(static_cast<int>(file_contents.size()), file_util::WriteFile(
- zip_source_dir.path().Append(FILE_PATH_LITERAL("file.txt")),
- file_contents.data(), file_contents.size()));
- ASSERT_TRUE(zip::Zip(zip_source_dir.path(), a_tmp, false));
+ zip::ZipContents zip_contents;
+ zip_contents[base::FilePath(FILE_PATH_LITERAL("file.txt"))] =
+ new base::RefCountedStaticMemory("dummy file", 10);
+ ASSERT_TRUE(zip::ZipFromMemory(a_tmp, zip_contents, false));
download_service_->CheckClientDownload(
&item,
@@ -725,10 +722,9 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadZip) {
Mock::VerifyAndClearExpectations(signature_util_.get());
// Now check with an executable in the zip file as well.
- ASSERT_EQ(static_cast<int>(file_contents.size()), file_util::WriteFile(
- zip_source_dir.path().Append(FILE_PATH_LITERAL("file.exe")),
- file_contents.data(), file_contents.size()));
- ASSERT_TRUE(zip::Zip(zip_source_dir.path(), a_tmp, false));
+ zip_contents[base::FilePath(FILE_PATH_LITERAL("file.exe"))] =
+ new base::RefCountedStaticMemory("dummy file", 10);
+ ASSERT_TRUE(zip::ZipFromMemory(a_tmp, zip_contents, false));
EXPECT_CALL(*sb_service_->mock_database_manager(),
MatchDownloadWhitelistUrl(_))

Powered by Google App Engine
This is Rietveld 408576698