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

Unified Diff: tests/CodexTest.cpp

Issue 1389053002: Focus SkScaledCodec on BitmapRegionDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@silenceNanobench
Patch Set: Detach returned codec Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« src/codec/SkScaledCodec.cpp ('K') | « src/codec/SkScaledCodec.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CodexTest.cpp
diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp
index f1c5bbaa128e1c989bf06af39f27f7a22e211864..b6ff08cdd7e149e4ad17c6fc83b01693ffeebebe 100644
--- a/tests/CodexTest.cpp
+++ b/tests/CodexTest.cpp
@@ -362,8 +362,11 @@ DEF_TEST(Codec_stripes, r) {
}
static void test_invalid_stream(skiatest::Reporter* r, const void* stream, size_t len) {
+ // Neither of these calls should return a codec. Bots should catch us if we leaked anything.
SkCodec* codec = SkCodec::NewFromStream(new SkMemoryStream(stream, len, false));
- // We should not have gotten a codec. Bots should catch us if we leaked anything.
+ REPORTER_ASSERT(r, !codec);
+
+ codec = SkScaledCodec::NewFromStream(new SkMemoryStream(stream, len, false));
REPORTER_ASSERT(r, !codec);
}
@@ -390,6 +393,16 @@ DEF_TEST(Codec_leaks, r) {
test_invalid_stream(r, emptyGif, sizeof(emptyGif));
}
+DEF_TEST(Codec_null, r) {
+ // Attempting to create an SkCodec or an SkScaledCodec with null should not
+ // crash.
+ SkCodec* codec = SkCodec::NewFromStream(nullptr);
+ REPORTER_ASSERT(r, !codec);
+
+ codec = SkScaledCodec::NewFromStream(nullptr);
+ REPORTER_ASSERT(r, !codec);
+}
+
static void test_dimensions(skiatest::Reporter* r, const char path[]) {
// Create the codec from the resource file
SkAutoTDelete<SkStream> stream(resource(path));
« src/codec/SkScaledCodec.cpp ('K') | « src/codec/SkScaledCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698