| OLD | NEW |
| 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 base::MessageLoop message_loop_; | 174 base::MessageLoop message_loop_; |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 TEST_F(ZipReaderTest, Open_ValidZipFile) { | 177 TEST_F(ZipReaderTest, Open_ValidZipFile) { |
| 178 ZipReader reader; | 178 ZipReader reader; |
| 179 ASSERT_TRUE(reader.Open(test_zip_file_)); | 179 ASSERT_TRUE(reader.Open(test_zip_file_)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 TEST_F(ZipReaderTest, Open_ValidZipPlatformFile) { | 182 TEST_F(ZipReaderTest, Open_ValidZipPlatformFile) { |
| 183 FileWrapper zip_fd_wrapper(test_zip_file_, FileWrapper::READ_ONLY); |
| 183 ZipReader reader; | 184 ZipReader reader; |
| 184 FileWrapper zip_fd_wrapper(test_zip_file_, FileWrapper::READ_ONLY); | |
| 185 ASSERT_TRUE(reader.OpenFromPlatformFile(zip_fd_wrapper.platform_file())); | 185 ASSERT_TRUE(reader.OpenFromPlatformFile(zip_fd_wrapper.platform_file())); |
| 186 } | 186 } |
| 187 | 187 |
| 188 TEST_F(ZipReaderTest, Open_NonExistentFile) { | 188 TEST_F(ZipReaderTest, Open_NonExistentFile) { |
| 189 ZipReader reader; | 189 ZipReader reader; |
| 190 ASSERT_FALSE(reader.Open(test_data_dir_.AppendASCII("nonexistent.zip"))); | 190 ASSERT_FALSE(reader.Open(test_data_dir_.AppendASCII("nonexistent.zip"))); |
| 191 } | 191 } |
| 192 | 192 |
| 193 TEST_F(ZipReaderTest, Open_ExistentButNonZipFile) { | 193 TEST_F(ZipReaderTest, Open_ExistentButNonZipFile) { |
| 194 ZipReader reader; | 194 ZipReader reader; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 } | 566 } |
| 567 | 567 |
| 568 // More than necessary byte read limit: must pass. | 568 // More than necessary byte read limit: must pass. |
| 569 EXPECT_TRUE(reader.ExtractCurrentEntryToString(16, &contents)); | 569 EXPECT_TRUE(reader.ExtractCurrentEntryToString(16, &contents)); |
| 570 EXPECT_EQ(i, contents.size()); | 570 EXPECT_EQ(i, contents.size()); |
| 571 EXPECT_EQ(0, memcmp(contents.c_str(), "0123456", i)); | 571 EXPECT_EQ(0, memcmp(contents.c_str(), "0123456", i)); |
| 572 } | 572 } |
| 573 reader.Close(); | 573 reader.Close(); |
| 574 } | 574 } |
| 575 | 575 |
| 576 // This test exposes http://crbug.com/430959, at least on OS X |
| 577 TEST_F(ZipReaderTest, DISABLED_LeakDetectionTest) { |
| 578 for (int i = 0; i < 2557; ++i) { |
| 579 FileWrapper zip_fd_wrapper(test_zip_file_, FileWrapper::READ_ONLY); |
| 580 ZipReader reader; |
| 581 ASSERT_TRUE(reader.OpenFromPlatformFile(zip_fd_wrapper.platform_file())); |
| 582 } |
| 583 } |
| 584 |
| 576 } // namespace zip | 585 } // namespace zip |
| OLD | NEW |