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

Side by Side Diff: tests/DrawFilterTest.cpp

Issue 1079813002: use anon namespace to avoid (silent) collisions between local test classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | « gm/drawfilter.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 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkDrawFilter.h" 9 #include "SkDrawFilter.h"
10 #include "SkSurface.h" 10 #include "SkSurface.h"
11 #include "Test.h" 11 #include "Test.h"
12 12
13 namespace {
13 class TestFilter : public SkDrawFilter { 14 class TestFilter : public SkDrawFilter {
14 public: 15 public:
15 bool filter(SkPaint* p, Type) override { 16 bool filter(SkPaint* p, Type) override {
16 return true; 17 return true;
17 } 18 }
18 }; 19 };
20 }
19 21
20 /** 22 /**
21 * canvas.setDrawFilter is defined to be local to the save/restore block, such that if you 23 * canvas.setDrawFilter is defined to be local to the save/restore block, such that if you
22 * do the following: save / modify-drawfilter / restore, the current drawfilter should be what 24 * do the following: save / modify-drawfilter / restore, the current drawfilter should be what
23 * it was before the save. 25 * it was before the save.
24 */ 26 */
25 static void test_saverestore(skiatest::Reporter* reporter) { 27 static void test_saverestore(skiatest::Reporter* reporter) {
26 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10)); 28 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10));
27 SkCanvas* canvas = surface->getCanvas(); 29 SkCanvas* canvas = surface->getCanvas();
28 30
29 31
30 SkAutoTUnref<TestFilter> df(SkNEW(TestFilter)); 32 SkAutoTUnref<TestFilter> df(SkNEW(TestFilter));
31 33
32 REPORTER_ASSERT(reporter, NULL == canvas->getDrawFilter()); 34 REPORTER_ASSERT(reporter, NULL == canvas->getDrawFilter());
33 35
34 canvas->save(); 36 canvas->save();
35 canvas->setDrawFilter(df); 37 canvas->setDrawFilter(df);
36 REPORTER_ASSERT(reporter, NULL != canvas->getDrawFilter()); 38 REPORTER_ASSERT(reporter, NULL != canvas->getDrawFilter());
37 canvas->restore(); 39 canvas->restore();
38 40
39 REPORTER_ASSERT(reporter, NULL == canvas->getDrawFilter()); 41 REPORTER_ASSERT(reporter, NULL == canvas->getDrawFilter());
40 } 42 }
41 43
42 DEF_TEST(DrawFilter, reporter) { 44 DEF_TEST(DrawFilter, reporter) {
43 test_saverestore(reporter); 45 test_saverestore(reporter);
44 } 46 }
OLDNEW
« no previous file with comments | « gm/drawfilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698