Revert[6] of add asserts around results from requestLock
This reverts commit 11e833d91b5ba2193ed593cb74900dddbec24b6f.
BUG=skia:
TBR=
Review URL: https://codereview.chromium.org/1159183003
diff --git a/tests/PixelRefTest.cpp b/tests/PixelRefTest.cpp
index e13d0e0..8a6e8e3 100644
--- a/tests/PixelRefTest.cpp
+++ b/tests/PixelRefTest.cpp
@@ -1,8 +1,63 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
#include "Test.h"
#include "SkMallocPixelRef.h"
#include "SkPixelRef.h"
+static void decrement_counter_proc(void* pixels, void* ctx) {
+ int* counter = (int*)ctx;
+ *counter -= 1;
+}
+
+static void test_dont_leak_install(skiatest::Reporter* reporter) {
+ bool success;
+ int release_counter;
+ SkImageInfo info;
+ SkBitmap bm;
+
+ info = SkImageInfo::MakeN32Premul(0, 0);
+ release_counter = 1;
+ success = bm.installPixels(info, NULL, 0, NULL, decrement_counter_proc, &release_counter);
+ REPORTER_ASSERT(reporter, true == success);
+ bm.reset();
+ REPORTER_ASSERT(reporter, 0 == release_counter);
+
+ info = SkImageInfo::MakeN32Premul(10, 10);
+ release_counter = 1;
+ success = bm.installPixels(info, NULL, 0, NULL, decrement_counter_proc, &release_counter);
+ REPORTER_ASSERT(reporter, true == success);
+ bm.reset();
+ REPORTER_ASSERT(reporter, 0 == release_counter);
+
+ info = SkImageInfo::MakeN32Premul(-10, -10);
+ release_counter = 1;
+ success = bm.installPixels(info, NULL, 0, NULL, decrement_counter_proc, &release_counter);
+ REPORTER_ASSERT(reporter, false == success);
+ bm.reset();
+ REPORTER_ASSERT(reporter, 0 == release_counter);
+}
+
+static void test_install(skiatest::Reporter* reporter) {
+ bool success;
+ SkImageInfo info = SkImageInfo::MakeN32Premul(0, 0);
+ SkBitmap bm;
+ // make sure we don't assert on an empty install
+ success = bm.installPixels(info, NULL, 0);
+ REPORTER_ASSERT(reporter, success);
+
+ // no pixels should be the same as setInfo()
+ info = SkImageInfo::MakeN32Premul(10, 10);
+ success = bm.installPixels(info, NULL, 0);
+ REPORTER_ASSERT(reporter, success);
+
+}
+
class TestListener : public SkPixelRef::GenIDChangeListener {
public:
explicit TestListener(int* ptr) : fPtr(ptr) {}
@@ -43,4 +98,7 @@
REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
pixelRef->addGenIDChangeListener(NULL);
pixelRef->notifyPixelsChanged();
+
+ test_install(r);
+ test_dont_leak_install(r);
}