OLD | NEW |
| (Empty) |
1 Writing Unit and Rendering Tests | |
2 ================================ | |
3 | |
4 Writing a Unit Test | |
5 ------------------- | |
6 | |
7 1. Add a file `tests/NewUnitTest.cpp`: | |
8 | |
9 <!--?prettify lang=cc?--> | |
10 | |
11 /* | |
12 * Copyright ........ | |
13 * | |
14 * Use of this source code is governed by a BSD-style license | |
15 * that can be found in the LICENSE file. | |
16 */ | |
17 #include "Test.h" | |
18 DEF_TEST(NewUnitTest, reporter) { | |
19 if (1 + 1 != 2) { | |
20 ERRORF(reporter, "%d + %d != %d", 1, 1, 2); | |
21 } | |
22 bool lifeIsGood = true; | |
23 REPORTER_ASSERT(reporter, lifeIsGood); | |
24 } | |
25 | |
26 2. Add a line to `gyp/tests.gypi`: | |
27 | |
28 '../tests/NewUnitTest.cpp', | |
29 | |
30 3. Recompile and run test: | |
31 | |
32 ./gyp_skia | |
33 ninja -C out/Debug dm | |
34 out/Debug/dm --match NewUnitTest | |
35 | |
36 Writing a Rendering Test | |
37 ------------------------ | |
38 | |
39 1. Add a file `gm/newgmtest.cpp`: | |
40 | |
41 <!--?prettify lang=cc?--> | |
42 | |
43 /* | |
44 * Copyright ........ | |
45 * | |
46 * Use of this source code is governed by a BSD-style license | |
47 * that can be found in the LICENSE file. | |
48 */ | |
49 #include "gm.h" | |
50 DEF_SIMPLE_GM(newgmtest, canvas, 128, 128) { | |
51 canvas->clear(SK_ColorWHITE); | |
52 SkPaint p; | |
53 p.setStrokeWidth(2); | |
54 canvas->drawLine(16, 16, 112, 112, p); | |
55 } | |
56 | |
57 2. Add a line to `gyp/gmslides.gypi`: | |
58 | |
59 '../gm/newgmtest.cpp', | |
60 | |
61 3. Recompile and run test: | |
62 | |
63 ./gyp_skia | |
64 ninja -C out/Debug dm | |
65 out/Debug/dm --match newgmtest | |
OLD | NEW |