| 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 "SkFrontBufferedStream.h" | 8 #include "SkFrontBufferedStream.h" |
| 9 #include "SkRefCnt.h" | 9 #include "SkRefCnt.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 private: | 189 private: |
| 190 const bool fHasLength; | 190 const bool fHasLength; |
| 191 const bool fHasPosition; | 191 const bool fHasPosition; |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 // Test all possible combinations of the wrapped stream having a length and a po
sition. | 194 // Test all possible combinations of the wrapped stream having a length and a po
sition. |
| 195 static void test_length_combos(skiatest::Reporter* reporter, size_t bufferSize)
{ | 195 static void test_length_combos(skiatest::Reporter* reporter, size_t bufferSize)
{ |
| 196 for (int hasLen = 0; hasLen <= 1; hasLen++) { | 196 for (int hasLen = 0; hasLen <= 1; hasLen++) { |
| 197 for (int hasPos = 0; hasPos <= 1; hasPos++) { | 197 for (int hasPos = 0; hasPos <= 1; hasPos++) { |
| 198 LengthOptionalStream stream((bool) hasLen, (bool) hasPos); | 198 LengthOptionalStream stream(SkToBool(hasLen), SkToBool(hasPos)); |
| 199 SkAutoTUnref<SkStream> buffered(SkFrontBufferedStream::Create(&strea
m, bufferSize)); | 199 SkAutoTUnref<SkStream> buffered(SkFrontBufferedStream::Create(&strea
m, bufferSize)); |
| 200 test_hasLength(reporter, *buffered.get(), stream); | 200 test_hasLength(reporter, *buffered.get(), stream); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Test using a stream with an initial offset. | 205 // Test using a stream with an initial offset. |
| 206 static void test_initial_offset(skiatest::Reporter* reporter, size_t bufferSize)
{ | 206 static void test_initial_offset(skiatest::Reporter* reporter, size_t bufferSize)
{ |
| 207 SkMemoryStream memStream(gAbcs, strlen(gAbcs), false); | 207 SkMemoryStream memStream(gAbcs, strlen(gAbcs), false); |
| 208 | 208 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 test_length_combos(reporter, bufferSize); | 242 test_length_combos(reporter, bufferSize); |
| 243 test_initial_offset(reporter, bufferSize); | 243 test_initial_offset(reporter, bufferSize); |
| 244 } | 244 } |
| 245 | 245 |
| 246 DEF_TEST(FrontBufferedStream, reporter) { | 246 DEF_TEST(FrontBufferedStream, reporter) { |
| 247 // Test 6 and 64, which are used by Android, as well as another arbitrary le
ngth. | 247 // Test 6 and 64, which are used by Android, as well as another arbitrary le
ngth. |
| 248 test_buffers(reporter, 6); | 248 test_buffers(reporter, 6); |
| 249 test_buffers(reporter, 15); | 249 test_buffers(reporter, 15); |
| 250 test_buffers(reporter, 64); | 250 test_buffers(reporter, 64); |
| 251 } | 251 } |
| OLD | NEW |