Index: remoting/base/compressor_zlib_unittest.cc |
diff --git a/remoting/base/compressor_zlib_unittest.cc b/remoting/base/compressor_zlib_unittest.cc |
index 9d65aad404819fda96cc6b64ce38946bf43cfc9e..8127350f29c1879197ec15863c7a2526af3c452b 100644 |
--- a/remoting/base/compressor_zlib_unittest.cc |
+++ b/remoting/base/compressor_zlib_unittest.cc |
@@ -21,22 +21,17 @@ static void Compress(remoting::Compressor* compressor, |
// Feed data into the compress until the end. |
// This loop will rewrite |output_data| continuously. |
- while (input_size) { |
- int consumed, written; |
- compressor->Write(input_data, input_size, |
- output_data, output_size, |
- &consumed, &written); |
+ int consumed = 0; |
+ int written = 0; |
+ while (compressor->Process(input_data, input_size, |
+ output_data, output_size, |
+ &consumed, &written)) { |
input_data += consumed; |
input_size -= consumed; |
} |
- |
- // And then flush the remaining data from the compressor. |
- int written; |
- while (compressor->Flush(output_data, output_size, &written)) { |
- } |
} |
-TEST(CompressorZlibTest, SimpleCompress) { |
+TEST(CompressorZlibTest, Compress) { |
static const int kRawDataSize = 1024 * 128; |
static const int kCompressedDataSize = 256; |
uint8 raw_data[kRawDataSize]; |
@@ -50,3 +45,20 @@ TEST(CompressorZlibTest, SimpleCompress) { |
Compress(&compressor, raw_data, kRawDataSize, |
compressed_data, kCompressedDataSize); |
} |
+ |
+// Checks that zlib can work with a small output buffer by reading |
+// less from the input. |
+TEST(CompressorZlibTest, SmallOutputBuffer) { |
+ static const int kRawDataSize = 1024 * 128; |
+ static const int kCompressedDataSize = 1; |
+ uint8 raw_data[kRawDataSize]; |
+ uint8 compressed_data[kCompressedDataSize]; |
+ |
+ // Generate the test data.g |
+ GenerateTestData(raw_data, kRawDataSize, 99); |
+ |
+ // Then use the compressor to compress. |
+ remoting::CompressorZlib compressor; |
+ Compress(&compressor, raw_data, kRawDataSize, |
+ compressed_data, kCompressedDataSize); |
+} |