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 class SkRRect;
23 
24 namespace {
25 
26 class TestCanvasBase : public SkCanvas {
27 public:
TestCanvasBase(int width,int height)28     TestCanvasBase(int width, int height) : SkCanvas(width, height) {}
onDrawAnnotation(const SkRect &,const char key[],SkData * value)29     void onDrawAnnotation(const SkRect&, const char key[], SkData* value) {
30         ADD_FAILURE() << "onDrawAnnotation not expected in this test";
31     }
onDrawDRRect(const SkRRect &,const SkRRect &,const SkPaint &)32     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) {
33         ADD_FAILURE() << "onDrawDRRect not expected in this test";
34     }
onDrawTextBlob(const SkTextBlob * blob,SkScalar x,SkScalar y,const SkPaint & paint)35     void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) {
36         ADD_FAILURE() << "onDrawTextBlob not expected in this test";
37     }
onDrawPatch(const SkPoint cubics[12],const SkColor colors[4],const SkPoint texCoords[4],SkBlendMode,const SkPaint & paint)38     void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4],
39                      SkBlendMode, const SkPaint& paint) {
40         ADD_FAILURE() << "onDrawPatch not expected in this test";
41     }
onDrawPaint(const SkPaint &)42     void onDrawPaint(const SkPaint&) { ADD_FAILURE() << "onDrawPaint not expected in this test"; }
onDrawRect(const SkRect &,const SkPaint &)43     void onDrawRect(const SkRect&, const SkPaint&) {
44         ADD_FAILURE() << "onDrawRect not expected in this test";
45     }
onDrawRegion(const SkRegion & region,const SkPaint & paint)46     void onDrawRegion(const SkRegion& region, const SkPaint& paint) {
47         ADD_FAILURE() << "onDrawRegion not expected in this test";
48     }
onDrawOval(const SkRect &,const SkPaint &)49     void onDrawOval(const SkRect&, const SkPaint&) {
50         ADD_FAILURE() << "onDrawOval not expected in this test";
51     }
onDrawArc(const SkRect &,SkScalar startAngle,SkScalar sweepAngle,bool useCenter,const SkPaint &)52     void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
53                    const SkPaint&) {
54         ADD_FAILURE() << "onDrawArc not expected in this test";
55     }
onDrawRRect(const SkRRect &,const SkPaint &)56     void onDrawRRect(const SkRRect&, const SkPaint&) {
57         ADD_FAILURE() << "onDrawRRect not expected in this test";
58     }
onDrawPoints(PointMode,size_t count,const SkPoint pts[],const SkPaint &)59     void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) {
60         ADD_FAILURE() << "onDrawPoints not expected in this test";
61     }
onDrawVerticesObject(const SkVertices *,SkBlendMode,const SkPaint &)62     void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) {
63         ADD_FAILURE() << "onDrawVertices not expected in this test";
64     }
onDrawAtlas2(const SkImage *,const SkRSXform[],const SkRect[],const SkColor[],int count,SkBlendMode,const SkSamplingOptions &,const SkRect * cull,const SkPaint *)65     void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
66                       SkBlendMode, const SkSamplingOptions&, const SkRect* cull, const SkPaint*) {
67         ADD_FAILURE() << "onDrawAtlas not expected in this test";
68     }
onDrawPath(const SkPath &,const SkPaint &)69     void onDrawPath(const SkPath&, const SkPaint&) {
70         ADD_FAILURE() << "onDrawPath not expected in this test";
71     }
onDrawImageRect2(const SkImage *,const SkRect &,const SkRect &,const SkSamplingOptions &,const SkPaint *,SrcRectConstraint)72     void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
73                           const SkPaint*, SrcRectConstraint) {
74         ADD_FAILURE() << "onDrawImageRect not expected in this test";
75     }
onDrawImageLattice2(const SkImage *,const Lattice & lattice,const SkRect & dst,SkFilterMode,const SkPaint *)76     void onDrawImageLattice2(const SkImage*, const Lattice& lattice, const SkRect& dst,
77                              SkFilterMode, const SkPaint*) {
78         ADD_FAILURE() << "onDrawImageLattice not expected in this test";
79     }
onClipRRect(const SkRRect & rrect,SkClipOp,ClipEdgeStyle)80     void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) {
81         ADD_FAILURE() << "onClipRRect not expected in this test";
82     }
onClipPath(const SkPath & path,SkClipOp,ClipEdgeStyle)83     void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) {
84         ADD_FAILURE() << "onClipPath not expected in this test";
85     }
onClipRegion(const SkRegion & deviceRgn,SkClipOp)86     void onClipRegion(const SkRegion& deviceRgn, SkClipOp) {
87         ADD_FAILURE() << "onClipRegion not expected in this test";
88     }
onDiscard()89     void onDiscard() { ADD_FAILURE() << "onDiscard not expected in this test"; }
onDrawPicture(const SkPicture *,const SkMatrix *,const SkPaint *)90     void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) {
91         ADD_FAILURE() << "onDrawPicture not expected in this test";
92     }
93 
94     int mDrawCounter = 0;  // counts how may draw calls of any kind were made to this canvas
95 };
96 }
97