blob: 9693ce7b67843c5f5fb17f0a019a9d80ab2377a5 [file] [log] [blame]
Stan Iliev52771272016-11-17 09:54:38 -05001/*
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
Stan Iliev52771272016-11-17 09:54:38 -050019#include <SkCanvas.h>
John Reck1bcacfd2017-11-03 10:12:19 -070020#include <gtest/gtest.h>
Stan Iliev52771272016-11-17 09:54:38 -050021
22namespace {
23
24class TestCanvasBase : public SkCanvas {
25public:
John Reck1bcacfd2017-11-03 10:12:19 -070026 TestCanvasBase(int width, int height) : SkCanvas(width, height) {}
Stan Iliev52771272016-11-17 09:54:38 -050027 void onDrawAnnotation(const SkRect&, const char key[], SkData* value) {
28 ADD_FAILURE() << "onDrawAnnotation not expected in this test";
29 }
30 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) {
31 ADD_FAILURE() << "onDrawDRRect not expected in this test";
32 }
33 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
John Reck1bcacfd2017-11-03 10:12:19 -070034 const SkPaint& paint) {
Stan Iliev52771272016-11-17 09:54:38 -050035 ADD_FAILURE() << "onDrawText not expected in this test";
36 }
37 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
John Reck1bcacfd2017-11-03 10:12:19 -070038 const SkPaint& paint) {
Stan Iliev52771272016-11-17 09:54:38 -050039 ADD_FAILURE() << "onDrawPosText not expected in this test";
40 }
41 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY,
John Reck1bcacfd2017-11-03 10:12:19 -070042 const SkPaint& paint) {
Stan Iliev52771272016-11-17 09:54:38 -050043 ADD_FAILURE() << "onDrawPosTextH not expected in this test";
44 }
45 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
John Reck1bcacfd2017-11-03 10:12:19 -070046 const SkMatrix* matrix, const SkPaint& paint) {
Stan Iliev52771272016-11-17 09:54:38 -050047 ADD_FAILURE() << "onDrawTextOnPath not expected in this test";
48 }
49 void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[],
John Reck1bcacfd2017-11-03 10:12:19 -070050 const SkRect* cullRect, const SkPaint& paint) {
Stan Iliev52771272016-11-17 09:54:38 -050051 ADD_FAILURE() << "onDrawTextRSXform not expected in this test";
52 }
53 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) {
54 ADD_FAILURE() << "onDrawTextBlob not expected in this test";
55 }
56 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4],
John Reck1bcacfd2017-11-03 10:12:19 -070057 SkBlendMode, const SkPaint& paint) {
Stan Iliev52771272016-11-17 09:54:38 -050058 ADD_FAILURE() << "onDrawPatch not expected in this test";
59 }
John Reck1bcacfd2017-11-03 10:12:19 -070060 void onDrawPaint(const SkPaint&) { ADD_FAILURE() << "onDrawPaint not expected in this test"; }
Stan Iliev52771272016-11-17 09:54:38 -050061 void onDrawRect(const SkRect&, const SkPaint&) {
62 ADD_FAILURE() << "onDrawRect not expected in this test";
63 }
64 void onDrawRegion(const SkRegion& region, const SkPaint& paint) {
65 ADD_FAILURE() << "onDrawRegion not expected in this test";
66 }
67 void onDrawOval(const SkRect&, const SkPaint&) {
68 ADD_FAILURE() << "onDrawOval not expected in this test";
69 }
70 void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
John Reck1bcacfd2017-11-03 10:12:19 -070071 const SkPaint&) {
Stan Iliev52771272016-11-17 09:54:38 -050072 ADD_FAILURE() << "onDrawArc not expected in this test";
73 }
74 void onDrawRRect(const SkRRect&, const SkPaint&) {
75 ADD_FAILURE() << "onDrawRRect not expected in this test";
76 }
77 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) {
78 ADD_FAILURE() << "onDrawPoints not expected in this test";
79 }
Mike Reed871cd2d2017-03-17 10:15:52 -040080 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) {
Stan Iliev52771272016-11-17 09:54:38 -050081 ADD_FAILURE() << "onDrawVertices not expected in this test";
82 }
83 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
John Reck1bcacfd2017-11-03 10:12:19 -070084 SkBlendMode, const SkRect* cull, const SkPaint*) {
Stan Iliev52771272016-11-17 09:54:38 -050085 ADD_FAILURE() << "onDrawAtlas not expected in this test";
86 }
87 void onDrawPath(const SkPath&, const SkPaint&) {
88 ADD_FAILURE() << "onDrawPath not expected in this test";
89 }
90 void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*) {
91 ADD_FAILURE() << "onDrawImage not expected in this test";
92 }
93 void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
John Reck1bcacfd2017-11-03 10:12:19 -070094 SrcRectConstraint) {
Stan Iliev52771272016-11-17 09:54:38 -050095 ADD_FAILURE() << "onDrawImageRect not expected in this test";
96 }
97 void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, const SkPaint*) {
98 ADD_FAILURE() << "onDrawImageNine not expected in this test";
99 }
100 void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
John Reck1bcacfd2017-11-03 10:12:19 -0700101 const SkPaint*) {
Stan Iliev52771272016-11-17 09:54:38 -0500102 ADD_FAILURE() << "onDrawImageLattice not expected in this test";
103 }
104 void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*) {
105 ADD_FAILURE() << "onDrawBitmap not expected in this test";
106 }
107 void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
John Reck1bcacfd2017-11-03 10:12:19 -0700108 SrcRectConstraint) {
Stan Iliev52771272016-11-17 09:54:38 -0500109 ADD_FAILURE() << "onDrawBitmapRect not expected in this test";
110 }
111 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
John Reck1bcacfd2017-11-03 10:12:19 -0700112 const SkPaint*) {
Stan Iliev52771272016-11-17 09:54:38 -0500113 ADD_FAILURE() << "onDrawBitmapNine not expected in this test";
114 }
115 void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst,
John Reck1bcacfd2017-11-03 10:12:19 -0700116 const SkPaint*) {
Stan Iliev52771272016-11-17 09:54:38 -0500117 ADD_FAILURE() << "onDrawBitmapLattice not expected in this test";
118 }
Mike Reedd43eaa92016-12-13 12:32:37 -0500119 void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) {
Stan Iliev52771272016-11-17 09:54:38 -0500120 ADD_FAILURE() << "onClipRRect not expected in this test";
121 }
Mike Reedd43eaa92016-12-13 12:32:37 -0500122 void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) {
Stan Iliev52771272016-11-17 09:54:38 -0500123 ADD_FAILURE() << "onClipPath not expected in this test";
124 }
Mike Reedd43eaa92016-12-13 12:32:37 -0500125 void onClipRegion(const SkRegion& deviceRgn, SkClipOp) {
Stan Iliev52771272016-11-17 09:54:38 -0500126 ADD_FAILURE() << "onClipRegion not expected in this test";
127 }
John Reck1bcacfd2017-11-03 10:12:19 -0700128 void onDiscard() { ADD_FAILURE() << "onDiscard not expected in this test"; }
Stan Iliev52771272016-11-17 09:54:38 -0500129 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) {
130 ADD_FAILURE() << "onDrawPicture not expected in this test";
131 }
132
John Reck1bcacfd2017-11-03 10:12:19 -0700133 int mDrawCounter = 0; // counts how may draw calls of any kind were made to this canvas
Stan Iliev52771272016-11-17 09:54:38 -0500134};
Stan Iliev52771272016-11-17 09:54:38 -0500135}