Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Side by Side Diff: tests/FrontBufferedStreamTest.cpp

Issue 1757333002: Fix bug in SkGifCodec / Switch SkImageDec tests to use Codec (Closed) Base URL: https://skia.googlesource.com/skia.git@m50
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/CodexTest.cpp ('k') | tests/GifTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCodec.h"
9 #include "SkFrontBufferedStream.h" 10 #include "SkFrontBufferedStream.h"
10 #include "SkImageDecoder.h"
11 #include "SkRefCnt.h" 11 #include "SkRefCnt.h"
12 #include "SkStream.h" 12 #include "SkStream.h"
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 #include "Test.h" 14 #include "Test.h"
15 15
16 static void test_read(skiatest::Reporter* reporter, SkStream* bufferedStream, 16 static void test_read(skiatest::Reporter* reporter, SkStream* bufferedStream,
17 const void* expectations, size_t bytesToRead) { 17 const void* expectations, size_t bytesToRead) {
18 // output for reading bufferedStream. 18 // output for reading bufferedStream.
19 SkAutoMalloc storage(bytesToRead); 19 SkAutoMalloc storage(bytesToRead);
20 20
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return fReadAfterEnd; 282 return fReadAfterEnd;
283 } 283 }
284 private: 284 private:
285 bool fAtEnd; 285 bool fAtEnd;
286 bool fReadAfterEnd; 286 bool fReadAfterEnd;
287 }; 287 };
288 288
289 DEF_TEST(ShortFrontBufferedStream, reporter) { 289 DEF_TEST(ShortFrontBufferedStream, reporter) {
290 FailingStream* failingStream = new FailingStream; 290 FailingStream* failingStream = new FailingStream;
291 SkAutoTDelete<SkStreamRewindable> stream(SkFrontBufferedStream::Create(faili ngStream, 64)); 291 SkAutoTDelete<SkStreamRewindable> stream(SkFrontBufferedStream::Create(faili ngStream, 64));
292 SkBitmap bm; 292
293 // The return value of DecodeStream is not important. We are just using Deco deStream because 293 // This will fail to create a codec. However, what we really want to test i s that we
294 // it simulates a bug. DecodeStream will read the stream, then rewind, then attempt to read 294 // won't read past the end of the stream.
295 // again. FrontBufferedStream::read should not continue to read its underlyi ng stream beyond 295 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
296 // its end.
297 SkImageDecoder::DecodeStream(stream, &bm);
298 REPORTER_ASSERT(reporter, !failingStream->readAfterEnd()); 296 REPORTER_ASSERT(reporter, !failingStream->readAfterEnd());
299 } 297 }
OLDNEW
« no previous file with comments | « tests/CodexTest.cpp ('k') | tests/GifTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698