OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
| 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
8 #include "SkFrontBufferedStream.h" | 10 #include "SkFrontBufferedStream.h" |
9 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
10 #include "SkStream.h" | 12 #include "SkStream.h" |
11 #include "SkTypes.h" | 13 #include "SkTypes.h" |
12 #include "Test.h" | |
13 | 14 |
14 static void test_read(skiatest::Reporter* reporter, SkStream* bufferedStream, | 15 static void test_read(skiatest::Reporter* reporter, SkStream* bufferedStream, |
15 const void* expectations, size_t bytesToRead) { | 16 const void* expectations, size_t bytesToRead) { |
16 // output for reading bufferedStream. | 17 // output for reading bufferedStream. |
17 SkAutoMalloc storage(bytesToRead); | 18 SkAutoMalloc storage(bytesToRead); |
18 | 19 |
19 size_t bytesRead = bufferedStream->read(storage.get(), bytesToRead); | 20 size_t bytesRead = bufferedStream->read(storage.get(), bytesToRead); |
20 REPORTER_ASSERT(reporter, bytesRead == bytesToRead || bufferedStream->isAtEn
d()); | 21 REPORTER_ASSERT(reporter, bytesRead == bytesToRead || bufferedStream->isAtEn
d()); |
21 REPORTER_ASSERT(reporter, memcmp(storage.get(), expectations, bytesRead) ==
0); | 22 REPORTER_ASSERT(reporter, memcmp(storage.get(), expectations, bytesRead) ==
0); |
22 } | 23 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 test_read(reporter, bufferedStream, gAbcs, bufferSize); | 144 test_read(reporter, bufferedStream, gAbcs, bufferSize); |
144 } | 145 } |
145 | 146 |
146 static void test_buffers(skiatest::Reporter* reporter, size_t bufferSize) { | 147 static void test_buffers(skiatest::Reporter* reporter, size_t bufferSize) { |
147 test_incremental_buffering(reporter, bufferSize); | 148 test_incremental_buffering(reporter, bufferSize); |
148 test_perfectly_sized_buffer(reporter, bufferSize); | 149 test_perfectly_sized_buffer(reporter, bufferSize); |
149 test_skipping(reporter, bufferSize); | 150 test_skipping(reporter, bufferSize); |
150 test_read_beyond_buffer(reporter, bufferSize); | 151 test_read_beyond_buffer(reporter, bufferSize); |
151 } | 152 } |
152 | 153 |
153 static void TestStreams(skiatest::Reporter* reporter) { | 154 DEF_TEST(FrontBufferedStream, reporter) { |
154 // Test 6 and 64, which are used by Android, as well as another arbitrary le
ngth. | 155 // Test 6 and 64, which are used by Android, as well as another arbitrary le
ngth. |
155 test_buffers(reporter, 6); | 156 test_buffers(reporter, 6); |
156 test_buffers(reporter, 15); | 157 test_buffers(reporter, 15); |
157 test_buffers(reporter, 64); | 158 test_buffers(reporter, 64); |
158 } | 159 } |
159 | |
160 #include "TestClassDef.h" | |
161 DEFINE_TESTCLASS("FrontBufferedStream", FrontBufferedStreamTestClass, TestStream
s) | |
OLD | NEW |