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

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: addressing comments Created 6 years, 9 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..a99bb6173c85b235f414b6ac00909420e621e69d 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -35,7 +35,7 @@
#include "net/url_request/url_request_status.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/zlib/google/zip.h"
+#include "third_party/zlib/google/zip_writer.h"
#include "url/gurl.h"
using ::testing::Assign;
@@ -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::ZipWriter writer;
+ writer.AddFile(base::FilePath(FILE_PATH_LITERAL("file.txt")),
+ base::StringPiece("dummy file", 10));
satorux1 2014/03/24 06:16:07 please drop ", 10". this should be unnecessary.
+ ASSERT_TRUE(writer.Commit(a_tmp, zip::ZipWriter::OverWrite));
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));
+ writer.AddFile(base::FilePath(FILE_PATH_LITERAL("file.exe")),
+ base::StringPiece("dummy file", 10));
satorux1 2014/03/24 06:16:07 ditto
+ ASSERT_TRUE(writer.Commit(a_tmp, zip::ZipWriter::OverWrite));
EXPECT_CALL(*sb_service_->mock_database_manager(),
MatchDownloadWhitelistUrl(_))

Powered by Google App Engine
This is Rietveld 408576698