| 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 <fstream> | 5 #include <fstream> |
| 6 #include <ostream> | 6 #include <ostream> |
| 7 | 7 |
| 8 #include "base/file_util.h" | 8 #include "base/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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 // Get the path of source data file. | 63 // Get the path of source data file. |
| 64 base::FilePath file_path; | 64 base::FilePath file_path; |
| 65 PathService::Get(base::DIR_SOURCE_ROOT, &file_path); | 65 PathService::Get(base::DIR_SOURCE_ROOT, &file_path); |
| 66 file_path = file_path.AppendASCII("net"); | 66 file_path = file_path.AppendASCII("net"); |
| 67 file_path = file_path.AppendASCII("data"); | 67 file_path = file_path.AppendASCII("data"); |
| 68 file_path = file_path.AppendASCII("filter_unittests"); | 68 file_path = file_path.AppendASCII("filter_unittests"); |
| 69 file_path = file_path.AppendASCII("google.txt"); | 69 file_path = file_path.AppendASCII("google.txt"); |
| 70 | 70 |
| 71 // Read data from the file into buffer. | 71 // Read data from the file into buffer. |
| 72 ASSERT_TRUE(file_util::ReadFileToString(file_path, &source_buffer_)); | 72 ASSERT_TRUE(base::ReadFileToString(file_path, &source_buffer_)); |
| 73 | 73 |
| 74 // Encode the data with deflate | 74 // Encode the data with deflate |
| 75 deflate_encode_buffer_ = new char[kDefaultBufferSize]; | 75 deflate_encode_buffer_ = new char[kDefaultBufferSize]; |
| 76 ASSERT_TRUE(deflate_encode_buffer_ != NULL); | 76 ASSERT_TRUE(deflate_encode_buffer_ != NULL); |
| 77 | 77 |
| 78 deflate_encode_len_ = kDefaultBufferSize; | 78 deflate_encode_len_ = kDefaultBufferSize; |
| 79 int code = CompressAll(ENCODE_DEFLATE , source_buffer(), source_len(), | 79 int code = CompressAll(ENCODE_DEFLATE , source_buffer(), source_len(), |
| 80 deflate_encode_buffer_, &deflate_encode_len_); | 80 deflate_encode_buffer_, &deflate_encode_len_); |
| 81 ASSERT_TRUE(code == Z_STREAM_END); | 81 ASSERT_TRUE(code == Z_STREAM_END); |
| 82 ASSERT_GT(deflate_encode_len_, 0); | 82 ASSERT_GT(deflate_encode_len_, 0); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 int corrupt_decode_size = kDefaultBufferSize; | 383 int corrupt_decode_size = kDefaultBufferSize; |
| 384 | 384 |
| 385 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len, | 385 int code = DecodeAllWithFilter(filter_.get(), corrupt_data, corrupt_data_len, |
| 386 corrupt_decode_buffer, &corrupt_decode_size); | 386 corrupt_decode_buffer, &corrupt_decode_size); |
| 387 | 387 |
| 388 // Expect failures | 388 // Expect failures |
| 389 EXPECT_TRUE(code == Filter::FILTER_ERROR); | 389 EXPECT_TRUE(code == Filter::FILTER_ERROR); |
| 390 } | 390 } |
| 391 | 391 |
| 392 } // namespace net | 392 } // namespace net |
| OLD | NEW |