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

Side by Side Diff: tests/PixelRefTest.cpp

Issue 1159733006: Revert[4] of add asserts around results from requestLock (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 | « src/core/SkPixelRef.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
1 #include "Test.h" 8 #include "Test.h"
2 9
3 #include "SkMallocPixelRef.h" 10 #include "SkMallocPixelRef.h"
4 #include "SkPixelRef.h" 11 #include "SkPixelRef.h"
5 12
13 static void test_install(skiatest::Reporter* reporter) {
14 bool success;
15 SkImageInfo info = SkImageInfo::MakeN32Premul(0, 0);
16 SkBitmap bm;
17 // make sure we don't assert on an empty install
18 success = bm.installPixels(info, NULL, 0);
19 REPORTER_ASSERT(reporter, success);
20
21 // no pixels should be the same as setInfo()
22 info = SkImageInfo::MakeN32Premul(10, 10);
23 success = bm.installPixels(info, NULL, 0);
24 REPORTER_ASSERT(reporter, success);
25 }
26
6 class TestListener : public SkPixelRef::GenIDChangeListener { 27 class TestListener : public SkPixelRef::GenIDChangeListener {
7 public: 28 public:
8 explicit TestListener(int* ptr) : fPtr(ptr) {} 29 explicit TestListener(int* ptr) : fPtr(ptr) {}
9 void onChange() override { (*fPtr)++; } 30 void onChange() override { (*fPtr)++; }
10 private: 31 private:
11 int* fPtr; 32 int* fPtr;
12 }; 33 };
13 34
14 DEF_TEST(PixelRef_GenIDChange, r) { 35 DEF_TEST(PixelRef_GenIDChange, r) {
15 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); 36 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
(...skipping 20 matching lines...) Expand all
36 // Force the generation ID to be recalculated, then add a listener. 57 // Force the generation ID to be recalculated, then add a listener.
37 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); 58 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
38 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count))); 59 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count)));
39 pixelRef->notifyPixelsChanged(); 60 pixelRef->notifyPixelsChanged();
40 REPORTER_ASSERT(r, 1 == count); 61 REPORTER_ASSERT(r, 1 == count);
41 62
42 // Quick check that NULL is safe. 63 // Quick check that NULL is safe.
43 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); 64 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
44 pixelRef->addGenIDChangeListener(NULL); 65 pixelRef->addGenIDChangeListener(NULL);
45 pixelRef->notifyPixelsChanged(); 66 pixelRef->notifyPixelsChanged();
67
68 test_install(r);
46 } 69 }
OLDNEW
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698