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

Side by Side Diff: third_party/zlib/google/zip_reader_unittest.cc

Issue 1552513002: Switch to standard integer types in third_party/zlib/google/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « third_party/zlib/google/zip_reader.cc ('k') | third_party/zlib/google/zip_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "third_party/zlib/google/zip_reader.h" 5 #include "third_party/zlib/google/zip_reader.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9 #include <string.h>
10
7 #include <set> 11 #include <set>
8 #include <string> 12 #include <string>
9 13
10 #include "base/bind.h" 14 #include "base/bind.h"
11 #include "base/files/file.h" 15 #include "base/files/file.h"
12 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 17 #include "base/files/scoped_temp_dir.h"
14 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/macros.h"
15 #include "base/md5.h" 20 #include "base/md5.h"
16 #include "base/path_service.h" 21 #include "base/path_service.h"
17 #include "base/run_loop.h" 22 #include "base/run_loop.h"
18 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
20 #include "base/time/time.h" 25 #include "base/time/time.h"
21 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
23 #include "testing/platform_test.h" 28 #include "testing/platform_test.h"
24 #include "third_party/zlib/google/zip_internal.h" 29 #include "third_party/zlib/google/zip_internal.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 void OnUnzipSuccess() { 78 void OnUnzipSuccess() {
74 success_calls_++; 79 success_calls_++;
75 } 80 }
76 81
77 // Failure callback for async functions. 82 // Failure callback for async functions.
78 void OnUnzipFailure() { 83 void OnUnzipFailure() {
79 failure_calls_++; 84 failure_calls_++;
80 } 85 }
81 86
82 // Progress callback for async functions. 87 // Progress callback for async functions.
83 void OnUnzipProgress(int64 progress) { 88 void OnUnzipProgress(int64_t progress) {
84 DCHECK(progress > current_progress_); 89 DCHECK(progress > current_progress_);
85 progress_calls_++; 90 progress_calls_++;
86 current_progress_ = progress; 91 current_progress_ = progress;
87 } 92 }
88 93
89 int success_calls() { return success_calls_; } 94 int success_calls() { return success_calls_; }
90 int failure_calls() { return failure_calls_; } 95 int failure_calls() { return failure_calls_; }
91 int progress_calls() { return progress_calls_; } 96 int progress_calls() { return progress_calls_; }
92 int current_progress() { return current_progress_; } 97 int current_progress() { return current_progress_; }
93 98
94 private: 99 private:
95 int success_calls_; 100 int success_calls_;
96 int failure_calls_; 101 int failure_calls_;
97 int progress_calls_; 102 int progress_calls_;
98 103
99 int64 current_progress_; 104 int64_t current_progress_;
100 }; 105 };
101 106
102 class MockWriterDelegate : public zip::WriterDelegate { 107 class MockWriterDelegate : public zip::WriterDelegate {
103 public: 108 public:
104 MOCK_METHOD0(PrepareOutput, bool()); 109 MOCK_METHOD0(PrepareOutput, bool());
105 MOCK_METHOD2(WriteBytes, bool(const char*, int)); 110 MOCK_METHOD2(WriteBytes, bool(const char*, int));
106 }; 111 };
107 112
108 } // namespace 113 } // namespace
109 114
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 EXPECT_EQ(1, listener.success_calls()); 505 EXPECT_EQ(1, listener.success_calls());
501 EXPECT_EQ(0, listener.failure_calls()); 506 EXPECT_EQ(0, listener.failure_calls());
502 EXPECT_LE(1, listener.progress_calls()); 507 EXPECT_LE(1, listener.progress_calls());
503 508
504 std::string output; 509 std::string output;
505 ASSERT_TRUE(base::ReadFileToString(test_dir_.AppendASCII("quux.txt"), 510 ASSERT_TRUE(base::ReadFileToString(test_dir_.AppendASCII("quux.txt"),
506 &output)); 511 &output));
507 const std::string md5 = base::MD5String(output); 512 const std::string md5 = base::MD5String(output);
508 EXPECT_EQ(kQuuxExpectedMD5, md5); 513 EXPECT_EQ(kQuuxExpectedMD5, md5);
509 514
510 int64 file_size = 0; 515 int64_t file_size = 0;
511 ASSERT_TRUE(base::GetFileSize(target_file, &file_size)); 516 ASSERT_TRUE(base::GetFileSize(target_file, &file_size));
512 517
513 EXPECT_EQ(file_size, listener.current_progress()); 518 EXPECT_EQ(file_size, listener.current_progress());
514 } 519 }
515 520
516 // Verifies that the asynchronous extraction to a file works. 521 // Verifies that the asynchronous extraction to a file works.
517 TEST_F(ZipReaderTest, ExtractToFileAsync_Directory) { 522 TEST_F(ZipReaderTest, ExtractToFileAsync_Directory) {
518 MockUnzipListener listener; 523 MockUnzipListener listener;
519 524
520 ZipReader reader; 525 ZipReader reader;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 ASSERT_TRUE(writer.PrepareOutput()); 683 ASSERT_TRUE(writer.PrepareOutput());
679 ASSERT_TRUE(writer.WriteBytes(kSomeData, kSomeDataLen)); 684 ASSERT_TRUE(writer.WriteBytes(kSomeData, kSomeDataLen));
680 } 685 }
681 ASSERT_EQ(kSomeDataLen, file_.GetLength()); 686 ASSERT_EQ(kSomeDataLen, file_.GetLength());
682 char buf[kSomeDataLen] = {}; 687 char buf[kSomeDataLen] = {};
683 ASSERT_EQ(kSomeDataLen, file_.Read(0LL, buf, kSomeDataLen)); 688 ASSERT_EQ(kSomeDataLen, file_.Read(0LL, buf, kSomeDataLen));
684 ASSERT_EQ(std::string(kSomeData), std::string(buf, kSomeDataLen)); 689 ASSERT_EQ(std::string(kSomeData), std::string(buf, kSomeDataLen));
685 } 690 }
686 691
687 } // namespace zip 692 } // namespace zip
OLDNEW
« no previous file with comments | « third_party/zlib/google/zip_reader.cc ('k') | third_party/zlib/google/zip_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698