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

Side by Side Diff: remoting/base/compressor_zlib_unittest.cc

Issue 11195029: Remove ZLib codec support from chromoting host and client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « remoting/base/compressor_zlib.cc ('k') | remoting/base/decompressor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdlib.h>
6
7 #include "remoting/base/compressor_zlib.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace remoting {
11
12 static void GenerateTestData(uint8* data, int size, int seed) {
13 srand(seed);
14 for (int i = 0; i < size; ++i)
15 data[i] = rand() % 256;
16 }
17
18 // Keep compressing |input_data| into |output_data| until the last
19 // bytes is consumed.
20 static void Compress(remoting::Compressor* compressor,
21 const uint8* input_data, int input_size,
22 uint8* output_data, int output_size) {
23
24 // Feed data into the compress until the end.
25 // This loop will rewrite |output_data| continuously.
26 int consumed = 0;
27 int written = 0;
28 while (compressor->Process(
29 input_data, input_size, output_data, output_size,
30 input_size == 0 ?
31 Compressor::CompressorFinish : Compressor::CompressorNoFlush,
32 &consumed, &written)) {
33 input_data += consumed;
34 input_size -= consumed;
35 }
36 }
37
38 TEST(CompressorZlibTest, Compress) {
39 static const int kRawDataSize = 1024 * 128;
40 static const int kCompressedDataSize = 256;
41 uint8 raw_data[kRawDataSize];
42 uint8 compressed_data[kCompressedDataSize];
43
44 // Generate the test data.g
45 GenerateTestData(raw_data, kRawDataSize, 99);
46
47 // Then use the compressor to compress.
48 remoting::CompressorZlib compressor;
49 Compress(&compressor, raw_data, kRawDataSize,
50 compressed_data, kCompressedDataSize);
51 }
52
53 // Checks that zlib can work with a small output buffer by reading
54 // less from the input.
55 TEST(CompressorZlibTest, SmallOutputBuffer) {
56 static const int kRawDataSize = 1024 * 128;
57 static const int kCompressedDataSize = 1;
58 uint8 raw_data[kRawDataSize];
59 uint8 compressed_data[kCompressedDataSize];
60
61 // Generate the test data.g
62 GenerateTestData(raw_data, kRawDataSize, 99);
63
64 // Then use the compressor to compress.
65 remoting::CompressorZlib compressor;
66 Compress(&compressor, raw_data, kRawDataSize,
67 compressed_data, kCompressedDataSize);
68 }
69
70 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/compressor_zlib.cc ('k') | remoting/base/decompressor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698