OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SkTypes.h" | |
8 | 7 |
9 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 #include "SkPaint.h" | 13 #include "SkPaint.h" |
14 #include "SkPoint.h" | 14 #include "SkPoint.h" |
15 #include "SkRect.h" | 15 #include "SkRect.h" |
16 | 16 #include "SkTypes.h" |
17 /////////////////////////////////////////////////////////////////////////////// | |
18 | 17 |
19 static const SkColor bgColor = SK_ColorWHITE; | 18 static const SkColor bgColor = SK_ColorWHITE; |
20 | 19 |
21 static void create(SkBitmap* bm, SkIRect bound, SkBitmap::Config config) { | 20 static void create(SkBitmap* bm, SkIRect bound, SkBitmap::Config config) { |
22 bm->setConfig(config, bound.width(), bound.height()); | 21 bm->setConfig(config, bound.width(), bound.height()); |
23 bm->allocPixels(); | 22 bm->allocPixels(); |
24 } | 23 } |
25 | 24 |
26 static void drawBG(SkCanvas* canvas) { | 25 static void drawBG(SkCanvas* canvas) { |
27 canvas->drawColor(bgColor); | 26 canvas->drawColor(bgColor); |
(...skipping 27 matching lines...) Expand all Loading... |
55 refColor = bgColor; | 54 refColor = bgColor; |
56 } | 55 } |
57 if (refColor != testColor) { | 56 if (refColor != testColor) { |
58 return false; | 57 return false; |
59 } | 58 } |
60 } | 59 } |
61 } | 60 } |
62 return true; | 61 return true; |
63 } | 62 } |
64 | 63 |
65 static void test_drawText(skiatest::Reporter* reporter) { | 64 DEF_TEST(DrawText, reporter) { |
66 | |
67 SkPaint paint; | 65 SkPaint paint; |
68 paint.setColor(SK_ColorGRAY); | 66 paint.setColor(SK_ColorGRAY); |
69 paint.setTextSize(SkIntToScalar(20)); | 67 paint.setTextSize(SkIntToScalar(20)); |
70 | 68 |
71 SkIRect drawTextRect = SkIRect::MakeWH(64, 64); | 69 SkIRect drawTextRect = SkIRect::MakeWH(64, 64); |
72 SkBitmap drawTextBitmap; | 70 SkBitmap drawTextBitmap; |
73 create(&drawTextBitmap, drawTextRect, SkBitmap::kARGB_8888_Config); | 71 create(&drawTextBitmap, drawTextRect, SkBitmap::kARGB_8888_Config); |
74 SkCanvas drawTextCanvas(drawTextBitmap); | 72 SkCanvas drawTextCanvas(drawTextBitmap); |
75 | 73 |
76 SkIRect drawPosTextRect = SkIRect::MakeWH(64, 64); | 74 SkIRect drawPosTextRect = SkIRect::MakeWH(64, 64); |
(...skipping 26 matching lines...) Expand all Loading... |
103 drawPosTextCanvas.drawPosText("A", 1, &point, paint); | 101 drawPosTextCanvas.drawPosText("A", 1, &point, paint); |
104 | 102 |
105 REPORTER_ASSERT(reporter, | 103 REPORTER_ASSERT(reporter, |
106 compare(drawTextBitmap, drawTextRect, | 104 compare(drawTextBitmap, drawTextRect, |
107 drawPosTextBitmap, drawPosTextRect)); | 105 drawPosTextBitmap, drawPosTextRect)); |
108 } | 106 } |
109 } | 107 } |
110 } | 108 } |
111 } | 109 } |
112 } | 110 } |
113 | |
114 #include "TestClassDef.h" | |
115 DEFINE_TESTCLASS("DrawText_DrawPosText", DrawTextTestClass, test_drawText) | |
OLD | NEW |