OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkFrontBufferedStream.h" | 10 #include "SkFrontBufferedStream.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // Only read the amount that was successfully peeked. | 276 // Only read the amount that was successfully peeked. |
277 const size_t bytesRead = bufferedStream->read(readStorage.get(), bytesPe
eked); | 277 const size_t bytesRead = bufferedStream->read(readStorage.get(), bytesPe
eked); |
278 REPORTER_ASSERT(r, bytesRead == bytesPeeked); | 278 REPORTER_ASSERT(r, bytesRead == bytesPeeked); |
279 REPORTER_ASSERT(r, !memcmp(peekStorage.get(), readStorage.get(), bytesPe
eked)); | 279 REPORTER_ASSERT(r, !memcmp(peekStorage.get(), readStorage.get(), bytesPe
eked)); |
280 | 280 |
281 // This should be safe to rewind. | 281 // This should be safe to rewind. |
282 REPORTER_ASSERT(r, bufferedStream->rewind()); | 282 REPORTER_ASSERT(r, bufferedStream->rewind()); |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 // This test uses file system operations that don't work out of the | 286 // This test uses file system operations that don't work out of the |
287 // box on iOS. It's likely that we don't need them on iOS. Ignoring for now. | 287 // box on iOS. It's likely that we don't need them on iOS. Ignoring for now. |
288 // TODO(stephana): Re-evaluate if we need this in the future. | 288 // TODO(stephana): Re-evaluate if we need this in the future. |
289 #ifndef SK_BUILD_FOR_IOS | 289 #ifndef SK_BUILD_FOR_IOS |
290 DEF_TEST(StreamPeek, reporter) { | 290 DEF_TEST(StreamPeek, reporter) { |
291 // Test a memory stream. | 291 // Test a memory stream. |
292 const char gAbcs[] = "abcdefghijklmnopqrstuvwxyz"; | 292 const char gAbcs[] = "abcdefghijklmnopqrstuvwxyz"; |
293 SkMemoryStream memStream(gAbcs, strlen(gAbcs), false); | 293 SkMemoryStream memStream(gAbcs, strlen(gAbcs), false); |
294 test_fully_peekable_stream(reporter, &memStream, memStream.getLength()); | 294 test_fully_peekable_stream(reporter, &memStream, memStream.getLength()); |
295 | 295 |
296 // Test an arbitrary file stream. file streams do not support peeking. | 296 // Test an arbitrary file stream. file streams do not support peeking. |
297 SkFILEStream fileStream(GetResourcePath("baby_tux.webp").c_str()); | 297 SkFILEStream fileStream(GetResourcePath("baby_tux.webp").c_str()); |
298 REPORTER_ASSERT(reporter, fileStream.isValid()); | 298 REPORTER_ASSERT(reporter, fileStream.isValid()); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 stream_copy_test(reporter, src, N, &dumbStream); | 427 stream_copy_test(reporter, src, N, &dumbStream); |
428 SkMemoryStream smartStream(src.get(), (size_t)N); | 428 SkMemoryStream smartStream(src.get(), (size_t)N); |
429 stream_copy_test(reporter, src, N, &smartStream); | 429 stream_copy_test(reporter, src, N, &smartStream); |
430 } | 430 } |
431 | 431 |
432 DEF_TEST(StreamEmptyStreamMemoryBase, r) { | 432 DEF_TEST(StreamEmptyStreamMemoryBase, r) { |
433 SkDynamicMemoryWStream tmp; | 433 SkDynamicMemoryWStream tmp; |
434 SkAutoTDelete<SkStreamAsset> asset(tmp.detachAsStream()); | 434 SkAutoTDelete<SkStreamAsset> asset(tmp.detachAsStream()); |
435 REPORTER_ASSERT(r, nullptr == asset->getMemoryBase()); | 435 REPORTER_ASSERT(r, nullptr == asset->getMemoryBase()); |
436 } | 436 } |
437 | |
OLD | NEW |