FatalTestCanvas.h revision d43eaa909018068bc1ac197839f5e2ed79d9139d
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 <gtest/gtest.h> 20#include <SkCanvas.h> 21 22namespace { 23 24class TestCanvasBase : public SkCanvas { 25public: 26 TestCanvasBase(int width, int height) : SkCanvas(width, height) { 27 } 28 void onDrawAnnotation(const SkRect&, const char key[], SkData* value) { 29 ADD_FAILURE() << "onDrawAnnotation not expected in this test"; 30 } 31 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) { 32 ADD_FAILURE() << "onDrawDRRect not expected in this test"; 33 } 34 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 35 const SkPaint& paint) { 36 ADD_FAILURE() << "onDrawText not expected in this test"; 37 } 38 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 39 const SkPaint& paint) { 40 ADD_FAILURE() << "onDrawPosText not expected in this test"; 41 } 42 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, 43 const SkPaint& paint) { 44 ADD_FAILURE() << "onDrawPosTextH not expected in this test"; 45 } 46 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 47 const SkMatrix* matrix, const SkPaint& paint) { 48 ADD_FAILURE() << "onDrawTextOnPath not expected in this test"; 49 } 50 void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[], 51 const SkRect* cullRect, const SkPaint& paint) { 52 ADD_FAILURE() << "onDrawTextRSXform not expected in this test"; 53 } 54 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) { 55 ADD_FAILURE() << "onDrawTextBlob not expected in this test"; 56 } 57 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], 58 SkBlendMode, const SkPaint& paint) { 59 ADD_FAILURE() << "onDrawPatch not expected in this test"; 60 } 61 void onDrawPaint(const SkPaint&) { 62 ADD_FAILURE() << "onDrawPaint not expected in this test"; 63 } 64 void onDrawRect(const SkRect&, const SkPaint&) { 65 ADD_FAILURE() << "onDrawRect not expected in this test"; 66 } 67 void onDrawRegion(const SkRegion& region, const SkPaint& paint) { 68 ADD_FAILURE() << "onDrawRegion not expected in this test"; 69 } 70 void onDrawOval(const SkRect&, const SkPaint&) { 71 ADD_FAILURE() << "onDrawOval not expected in this test"; 72 } 73 void onDrawArc(const SkRect&, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, 74 const SkPaint&) { 75 ADD_FAILURE() << "onDrawArc not expected in this test"; 76 } 77 void onDrawRRect(const SkRRect&, const SkPaint&) { 78 ADD_FAILURE() << "onDrawRRect not expected in this test"; 79 } 80 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) { 81 ADD_FAILURE() << "onDrawPoints not expected in this test"; 82 } 83 void onDrawVertices(VertexMode, int vertexCount, const SkPoint vertices[], const SkPoint texs[], 84 const SkColor colors[], SkBlendMode, const uint16_t indices[], int indexCount, 85 const SkPaint&) { 86 ADD_FAILURE() << "onDrawVertices not expected in this test"; 87 } 88 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count, 89 SkBlendMode, const SkRect* cull, const SkPaint*) { 90 ADD_FAILURE() << "onDrawAtlas not expected in this test"; 91 } 92 void onDrawPath(const SkPath&, const SkPaint&) { 93 ADD_FAILURE() << "onDrawPath not expected in this test"; 94 } 95 void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*) { 96 ADD_FAILURE() << "onDrawImage not expected in this test"; 97 } 98 void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*, 99 SrcRectConstraint) { 100 ADD_FAILURE() << "onDrawImageRect not expected in this test"; 101 } 102 void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, const SkPaint*) { 103 ADD_FAILURE() << "onDrawImageNine not expected in this test"; 104 } 105 void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst, 106 const SkPaint*) { 107 ADD_FAILURE() << "onDrawImageLattice not expected in this test"; 108 } 109 void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*) { 110 ADD_FAILURE() << "onDrawBitmap not expected in this test"; 111 } 112 void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, 113 SrcRectConstraint) { 114 ADD_FAILURE() << "onDrawBitmapRect not expected in this test"; 115 } 116 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, 117 const SkPaint*) { 118 ADD_FAILURE() << "onDrawBitmapNine not expected in this test"; 119 } 120 void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst, 121 const SkPaint*) { 122 ADD_FAILURE() << "onDrawBitmapLattice not expected in this test"; 123 } 124 void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) { 125 ADD_FAILURE() << "onClipRRect not expected in this test"; 126 } 127 void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) { 128 ADD_FAILURE() << "onClipPath not expected in this test"; 129 } 130 void onClipRegion(const SkRegion& deviceRgn, SkClipOp) { 131 ADD_FAILURE() << "onClipRegion not expected in this test"; 132 } 133 void onDiscard() { 134 ADD_FAILURE() << "onDiscard not expected in this test"; 135 } 136 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) { 137 ADD_FAILURE() << "onDrawPicture not expected in this test"; 138 } 139 140 int mDrawCounter = 0; //counts how may draw calls of any kind were made to this canvas 141}; 142 143}