1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <SkCanvas.h>
20 #include <gtest/gtest.h>
21 
22 namespace {
23 
24 class TestCanvasBase : public SkCanvas {
25 public:
TestCanvasBase(int width,int height)26     TestCanvasBase(int width, int height) : SkCanvas(width, height) {}
onDrawAnnotation(const SkRect &,const char key[],SkData * value)27     void onDrawAnnotation(const SkRect&, const char key[], SkData* value) {
28         ADD_FAILURE() << "onDrawAnnotation not expected in this test";
29     }
onDrawDRRect(const SkRRect &,const SkRRect &,const SkPaint &)30     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) {
31         ADD_FAILURE() << "onDrawDRRect not expected in this test";
32     }
onDrawTextBlob(const SkTextBlob * blob,SkScalar x,SkScalar y,const SkPaint & paint)33     void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) {
34         ADD_FAILURE() << "onDrawTextBlob not expected in this test";
35     }
onDrawPatch(const SkPoint cubics[12],const SkColor colors[4],const SkPoint texCoords[4],SkBlendMode,const SkPaint & paint)36     void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4],
37                      SkBlendMode, const SkPaint& paint) {
38         ADD_FAILURE() << "onDrawPatch not expected in this test";
39     }
onDrawPaint(const SkPaint &)40     void onDrawPaint(const SkPaint&) { ADD_FAILURE() << "onDrawPaint not expected in this test"; }
onDrawRect(const SkRect &,const SkPaint &)41     void onDrawRect(const SkRect&, const SkPaint&) {
42         ADD_FAILURE() << "onDrawRect not expected in this test";
43     }
onDrawRegion(const SkRegion & region,const SkPaint & paint)44     void onDrawRegion(const SkRegion& region, const SkPaint& paint) {
45         ADD_FAILURE() << "onDrawRegion not expected in this test";
46     }
onDrawOval(const SkRect &,const SkPaint &)47     void onDrawOval(const SkRect&, const SkPaint&) {
48         ADD_FAILURE() << "onDrawOval not expected in this test";
49     }
onDrawArc(const SkRect &,SkScalar startAngle,SkScalar sweepAngle,bool useCenter,const SkPaint &)50     void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
51                    const SkPaint&) {
52         ADD_FAILURE() << "onDrawArc not expected in this test";
53     }
onDrawRRect(const SkRRect &,const SkPaint &)54     void onDrawRRect(const SkRRect&, const SkPaint&) {
55         ADD_FAILURE() << "onDrawRRect not expected in this test";
56     }
onDrawPoints(PointMode,size_t count,const SkPoint pts[],const SkPaint &)57     void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) {
58         ADD_FAILURE() << "onDrawPoints not expected in this test";
59     }
onDrawVerticesObject(const SkVertices *,SkBlendMode,const SkPaint &)60     void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) {
61         ADD_FAILURE() << "onDrawVertices not expected in this test";
62     }
onDrawAtlas(const SkImage *,const SkRSXform[],const SkRect[],const SkColor[],int count,SkBlendMode,const SkRect * cull,const SkPaint *)63     void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
64                      SkBlendMode, const SkRect* cull, const SkPaint*) {
65         ADD_FAILURE() << "onDrawAtlas not expected in this test";
66     }
onDrawPath(const SkPath &,const SkPaint &)67     void onDrawPath(const SkPath&, const SkPaint&) {
68         ADD_FAILURE() << "onDrawPath not expected in this test";
69     }
onDrawImage(const SkImage *,SkScalar dx,SkScalar dy,const SkPaint *)70     void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*) {
71         ADD_FAILURE() << "onDrawImage not expected in this test";
72     }
onDrawImageRect(const SkImage *,const SkRect *,const SkRect &,const SkPaint *,SrcRectConstraint)73     void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
74                          SrcRectConstraint) {
75         ADD_FAILURE() << "onDrawImageRect not expected in this test";
76     }
onDrawImageNine(const SkImage *,const SkIRect & center,const SkRect & dst,const SkPaint *)77     void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, const SkPaint*) {
78         ADD_FAILURE() << "onDrawImageNine not expected in this test";
79     }
onDrawImageLattice(const SkImage *,const Lattice & lattice,const SkRect & dst,const SkPaint *)80     void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
81                             const SkPaint*) {
82         ADD_FAILURE() << "onDrawImageLattice not expected in this test";
83     }
onDrawBitmap(const SkBitmap &,SkScalar dx,SkScalar dy,const SkPaint *)84     void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*) {
85         ADD_FAILURE() << "onDrawBitmap not expected in this test";
86     }
onDrawBitmapRect(const SkBitmap &,const SkRect *,const SkRect &,const SkPaint *,SrcRectConstraint)87     void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
88                           SrcRectConstraint) {
89         ADD_FAILURE() << "onDrawBitmapRect not expected in this test";
90     }
onDrawBitmapNine(const SkBitmap &,const SkIRect & center,const SkRect & dst,const SkPaint *)91     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
92                           const SkPaint*) {
93         ADD_FAILURE() << "onDrawBitmapNine not expected in this test";
94     }
onDrawBitmapLattice(const SkBitmap &,const Lattice & lattice,const SkRect & dst,const SkPaint *)95     void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst,
96                              const SkPaint*) {
97         ADD_FAILURE() << "onDrawBitmapLattice not expected in this test";
98     }
onClipRRect(const SkRRect & rrect,SkClipOp,ClipEdgeStyle)99     void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) {
100         ADD_FAILURE() << "onClipRRect not expected in this test";
101     }
onClipPath(const SkPath & path,SkClipOp,ClipEdgeStyle)102     void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) {
103         ADD_FAILURE() << "onClipPath not expected in this test";
104     }
onClipRegion(const SkRegion & deviceRgn,SkClipOp)105     void onClipRegion(const SkRegion& deviceRgn, SkClipOp) {
106         ADD_FAILURE() << "onClipRegion not expected in this test";
107     }
onDiscard()108     void onDiscard() { ADD_FAILURE() << "onDiscard not expected in this test"; }
onDrawPicture(const SkPicture *,const SkMatrix *,const SkPaint *)109     void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) {
110         ADD_FAILURE() << "onDrawPicture not expected in this test";
111     }
112 
113     int mDrawCounter = 0;  // counts how may draw calls of any kind were made to this canvas
114 };
115 }
116