OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <fstream> | 5 #include <fstream> |
6 #include <ostream> | 6 #include <ostream> |
7 | 7 |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 }; | 42 }; |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 namespace net { | 46 namespace net { |
47 | 47 |
48 // These tests use the path service, which uses autoreleased objects on the | 48 // These tests use the path service, which uses autoreleased objects on the |
49 // Mac, so this needs to be a PlatformTest. | 49 // Mac, so this needs to be a PlatformTest. |
50 class GZipUnitTest : public PlatformTest { | 50 class GZipUnitTest : public PlatformTest { |
51 protected: | 51 protected: |
52 virtual void SetUp() { | 52 void SetUp() override { |
53 PlatformTest::SetUp(); | 53 PlatformTest::SetUp(); |
54 | 54 |
55 deflate_encode_buffer_ = NULL; | 55 deflate_encode_buffer_ = NULL; |
56 gzip_encode_buffer_ = NULL; | 56 gzip_encode_buffer_ = NULL; |
57 | 57 |
58 // Get the path of source data file. | 58 // Get the path of source data file. |
59 base::FilePath file_path; | 59 base::FilePath file_path; |
60 PathService::Get(base::DIR_SOURCE_ROOT, &file_path); | 60 PathService::Get(base::DIR_SOURCE_ROOT, &file_path); |
61 file_path = file_path.AppendASCII("net"); | 61 file_path = file_path.AppendASCII("net"); |
62 file_path = file_path.AppendASCII("data"); | 62 file_path = file_path.AppendASCII("data"); |
(...skipping 19 matching lines...) Expand all Loading... |
82 ASSERT_TRUE(gzip_encode_buffer_ != NULL); | 82 ASSERT_TRUE(gzip_encode_buffer_ != NULL); |
83 | 83 |
84 gzip_encode_len_ = kDefaultBufferSize; | 84 gzip_encode_len_ = kDefaultBufferSize; |
85 code = CompressAll(ENCODE_GZIP, source_buffer(), source_len(), | 85 code = CompressAll(ENCODE_GZIP, source_buffer(), source_len(), |
86 gzip_encode_buffer_, &gzip_encode_len_); | 86 gzip_encode_buffer_, &gzip_encode_len_); |
87 ASSERT_TRUE(code == Z_STREAM_END); | 87 ASSERT_TRUE(code == Z_STREAM_END); |
88 ASSERT_GT(gzip_encode_len_, 0); | 88 ASSERT_GT(gzip_encode_len_, 0); |
89 ASSERT_TRUE(gzip_encode_len_ <= kDefaultBufferSize); | 89 ASSERT_TRUE(gzip_encode_len_ <= kDefaultBufferSize); |
90 } | 90 } |
91 | 91 |
92 virtual void TearDown() { | 92 void TearDown() override { |
93 delete[] deflate_encode_buffer_; | 93 delete[] deflate_encode_buffer_; |
94 deflate_encode_buffer_ = NULL; | 94 deflate_encode_buffer_ = NULL; |
95 | 95 |
96 delete[] gzip_encode_buffer_; | 96 delete[] gzip_encode_buffer_; |
97 gzip_encode_buffer_ = NULL; | 97 gzip_encode_buffer_ = NULL; |
98 | 98 |
99 PlatformTest::TearDown(); | 99 PlatformTest::TearDown(); |
100 } | 100 } |
101 | 101 |
102 // Compress the data in source with deflate encoding and write output to the | 102 // Compress the data in source with deflate encoding and write output to the |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 int corrupt_decode_size = kDefaultBufferSize; | 378 int corrupt_decode_size = kDefaultBufferSize; |
379 | 379 |
380 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len, | 380 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len, |
381 corrupt_decode_buffer, &corrupt_decode_size); | 381 corrupt_decode_buffer, &corrupt_decode_size); |
382 | 382 |
383 // Expect failures | 383 // Expect failures |
384 EXPECT_TRUE(code == Filter::FILTER_ERROR); | 384 EXPECT_TRUE(code == Filter::FILTER_ERROR); |
385 } | 385 } |
386 | 386 |
387 } // namespace net | 387 } // namespace net |
OLD | NEW |