diff options
author | scroggo <scroggo@google.com> | 2016-02-18 05:59:25 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-18 05:59:25 -0800 |
commit | ef0fed3bf06de231b66be5f5279468afd01e6f75 (patch) | |
tree | 6354bcd42067a865522af79c208aca2f907a3a8c /tests/FrontBufferedStreamTest.cpp | |
parent | 6b14c6b329fde5402ce7458d8261e80944279d06 (diff) |
Remove position from FrontBufferedStream
When FrontBufferedStream was written, it implemented getPosition()
and returned true for hasPosition(). The CL that introduced it
(crrev.com/23717055) does not have any indication why, but I'm guessing
it was because it was easy to implement. None of our decoders rely on
this (only some tests do).
Now that we have a decoder (SkRawCodec) that expects to be able to seek
a stream if it has a position (which makes sense - SkStream.h
associates that with SkStreamSeekable, and there is no other way to
check to see if a stream is seekable), it is failing because
FrontBufferedStream reports it has a position and the decoder tries to
seek.
Remove FrontBufferedStream::hasPosition() (reverting to the default,
false) and ::getPosition() (so it will return 0).
Fix tests - do not call FrontBufferedStream::getPosition()
Update CodexTest to test using an FrontBufferedStream, like Android
does.
BUG=b/27218441
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1703293002
Review URL: https://codereview.chromium.org/1703293002
Diffstat (limited to 'tests/FrontBufferedStreamTest.cpp')
-rw-r--r-- | tests/FrontBufferedStreamTest.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/FrontBufferedStreamTest.cpp b/tests/FrontBufferedStreamTest.cpp index 0b161b96d8..7821c5e40d 100644 --- a/tests/FrontBufferedStreamTest.cpp +++ b/tests/FrontBufferedStreamTest.cpp @@ -68,7 +68,7 @@ static void test_incremental_buffering(skiatest::Reporter* reporter, size_t buff test_read(reporter, bufferedStream, gAbcs, bufferSize / 4); // Now test reading part of what was buffered, and buffering new data. - test_read(reporter, bufferedStream, gAbcs + bufferedStream->getPosition(), bufferSize / 2); + test_read(reporter, bufferedStream, gAbcs + bufferSize / 4, bufferSize / 2); // Now test reading what was buffered, buffering new data, and // reading directly from the stream. @@ -96,7 +96,7 @@ static void test_perfectly_sized_buffer(skiatest::Reporter* reporter, size_t buf test_read(reporter, bufferedStream, gAbcs, bufferSize); // Read past the size of the buffer. At this point, we cannot return. - test_read(reporter, bufferedStream, gAbcs + bufferedStream->getPosition(), 1); + test_read(reporter, bufferedStream, gAbcs + memStream->getPosition(), 1); test_rewind(reporter, bufferedStream, false); } @@ -116,7 +116,7 @@ static void test_skipping(skiatest::Reporter* reporter, size_t bufferSize) { bufferedStream->skip(bufferSize / 2); // Test that reading will still work. - test_read(reporter, bufferedStream, gAbcs + bufferedStream->getPosition(), bufferSize / 4); + test_read(reporter, bufferedStream, gAbcs + memStream->getPosition(), bufferSize / 4); test_rewind(reporter, bufferedStream, true); test_read(reporter, bufferedStream, gAbcs, bufferSize); @@ -219,13 +219,12 @@ static void test_initial_offset(skiatest::Reporter* reporter, size_t bufferSize) memStream->skip(arbitraryOffset); SkAutoTDelete<SkStream> bufferedStream(SkFrontBufferedStream::Create(memStream, bufferSize)); - // Since SkMemoryStream has a length and a position, bufferedStream must also. + // Since SkMemoryStream has a length, bufferedStream must also. REPORTER_ASSERT(reporter, bufferedStream->hasLength()); const size_t amountToRead = 10; const size_t bufferedLength = bufferedStream->getLength(); - size_t currentPosition = bufferedStream->getPosition(); - REPORTER_ASSERT(reporter, 0 == currentPosition); + size_t currentPosition = 0; // Read the stream in chunks. After each read, the position must match currentPosition, // which sums the amount attempted to read, unless the end of the stream has been reached. @@ -235,7 +234,7 @@ static void test_initial_offset(skiatest::Reporter* reporter, size_t bufferSize) test_read(reporter, bufferedStream, gAbcs + arbitraryOffset + currentPosition, amountToRead); currentPosition = SkTMin(currentPosition + amountToRead, bufferedLength); - REPORTER_ASSERT(reporter, bufferedStream->getPosition() == currentPosition); + REPORTER_ASSERT(reporter, memStream->getPosition() - arbitraryOffset == currentPosition); } REPORTER_ASSERT(reporter, bufferedStream->isAtEnd()); REPORTER_ASSERT(reporter, bufferedLength == currentPosition); |