OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #include <stdlib.h> | 8 #include <stdlib.h> |
11 #include <string.h> | 9 #include <string.h> |
12 | 10 |
13 #include "Test.h" | 11 #include "Test.h" |
| 12 #include "TestClassDef.h" |
14 #include "SkData.h" | 13 #include "SkData.h" |
15 #include "SkFlate.h" | 14 #include "SkFlate.h" |
16 #include "SkStream.h" | 15 #include "SkStream.h" |
17 | 16 |
18 // A memory stream that reports zero size with the standard call, like | 17 // A memory stream that reports zero size with the standard call, like |
19 // an unseekable file stream would. | 18 // an unseekable file stream would. |
20 class SkZeroSizeMemStream : public SkMemoryStream { | 19 class SkZeroSizeMemStream : public SkMemoryStream { |
21 public: | 20 public: |
22 virtual size_t read(void* buffer, size_t size) { | 21 virtual size_t read(void* buffer, size_t size) { |
23 if (buffer == NULL && size == 0) | 22 if (buffer == NULL && size == 0) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 data1->size()) == 0); | 77 data1->size()) == 0); |
79 | 78 |
80 // Check that the uncompressed data matches the source data. | 79 // Check that the uncompressed data matches the source data. |
81 SkAutoDataUnref data2(uncompressed.copyToData()); | 80 SkAutoDataUnref data2(uncompressed.copyToData()); |
82 REPORTER_ASSERT(reporter, testData.getLength() == uncompressed.getOffset()); | 81 REPORTER_ASSERT(reporter, testData.getLength() == uncompressed.getOffset()); |
83 REPORTER_ASSERT(reporter, memcmp(testData.getMemoryBase(), | 82 REPORTER_ASSERT(reporter, memcmp(testData.getMemoryBase(), |
84 data2->data(), | 83 data2->data(), |
85 testData.getLength()) == 0); | 84 testData.getLength()) == 0); |
86 } | 85 } |
87 | 86 |
88 static void TestFlateCompression(skiatest::Reporter* reporter) { | 87 DEF_TEST(Flate, reporter) { |
89 TestFlate(reporter, NULL, 0); | 88 TestFlate(reporter, NULL, 0); |
90 #if defined(SK_ZLIB_INCLUDE) && !defined(SK_DEBUG) | 89 #if defined(SK_ZLIB_INCLUDE) && !defined(SK_DEBUG) |
91 REPORTER_ASSERT(reporter, SkFlate::HaveFlate()); | 90 REPORTER_ASSERT(reporter, SkFlate::HaveFlate()); |
92 | 91 |
93 SkMemoryStream memStream; | 92 SkMemoryStream memStream; |
94 TestFlate(reporter, &memStream, 512); | 93 TestFlate(reporter, &memStream, 512); |
95 TestFlate(reporter, &memStream, 10240); | 94 TestFlate(reporter, &memStream, 10240); |
96 | 95 |
97 SkZeroSizeMemStream fileStream; | 96 SkZeroSizeMemStream fileStream; |
98 TestFlate(reporter, &fileStream, 512); | 97 TestFlate(reporter, &fileStream, 512); |
99 TestFlate(reporter, &fileStream, 10240); | 98 TestFlate(reporter, &fileStream, 10240); |
100 #endif | 99 #endif |
101 } | 100 } |
102 | |
103 #include "TestClassDef.h" | |
104 DEFINE_TESTCLASS("Flate", FlateTestClass, TestFlateCompression) | |
OLD | NEW |