Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/AndroidPaintTest.cpp

Issue 117863005: Get rid of DEFINE_TESTCLASS_SHORT() macro. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Mike review Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/PathOpsAngleTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // SkPaints only have an SkPaintOptionsAndroid if SK_BUILD_FOR_ANDROID is true. 1 // SkPaints only have an SkPaintOptionsAndroid if SK_BUILD_FOR_ANDROID is true.
2 #ifdef SK_BUILD_FOR_ANDROID 2 #ifdef SK_BUILD_FOR_ANDROID
3 3
4 #include "SkPaintOptionsAndroid.h" 4 #include "SkPaintOptionsAndroid.h"
5 #include "SkOrderedReadBuffer.h" 5 #include "SkOrderedReadBuffer.h"
6 #include "SkOrderedWriteBuffer.h" 6 #include "SkOrderedWriteBuffer.h"
7 #include "SkPaint.h" 7 #include "SkPaint.h"
8 #include "Test.h" 8 #include "Test.h"
9 #include "TestClassDef.h" 9 #include "TestClassDef.h"
10 10
11 static size_t Reconstruct(const SkPaint& src, SkPaint* dst) { 11 static size_t Reconstruct(const SkPaint& src, SkPaint* dst) {
12 SkOrderedWriteBuffer writer(64 /*arbitrary*/); 12 SkOrderedWriteBuffer writer(64 /*arbitrary*/);
13 src.flatten(writer); 13 src.flatten(writer);
14 14
15 const size_t size = writer.bytesWritten(); 15 const size_t size = writer.bytesWritten();
16 SkAutoMalloc bytes(size); 16 SkAutoMalloc bytes(size);
17 writer.writeToMemory(bytes.get()); 17 writer.writeToMemory(bytes.get());
18 18
19 SkOrderedReadBuffer reader(bytes.get(), size); 19 SkOrderedReadBuffer reader(bytes.get(), size);
20 dst->unflatten(reader); 20 dst->unflatten(reader);
21 21
22 return size; 22 return size;
23 } 23 }
24 24
25 static void android_options_serialization(skiatest::Reporter* reporter) { 25 DEF_TEST(AndroidOptionsSerialization, reporter) {
26 // We want to make sure that Android's paint options survive a flatten/unfla tten round trip. 26 // We want to make sure that Android's paint options survive a flatten/unfla tten round trip.
27 // These are all non-default options. 27 // These are all non-default options.
28 SkPaintOptionsAndroid options; 28 SkPaintOptionsAndroid options;
29 options.setLanguage("ja-JP"); 29 options.setLanguage("ja-JP");
30 options.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant); 30 options.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant);
31 options.setUseFontFallbacks(true); 31 options.setUseFontFallbacks(true);
32 32
33 SkPaint paint; 33 SkPaint paint;
34 paint.setPaintOptionsAndroid(options); 34 paint.setPaintOptionsAndroid(options);
35 35
36 SkPaint reconstructed; 36 SkPaint reconstructed;
37 Reconstruct(paint, &reconstructed); 37 Reconstruct(paint, &reconstructed);
38 38
39 REPORTER_ASSERT(reporter, options == reconstructed.getPaintOptionsAndroid()) ; 39 REPORTER_ASSERT(reporter, options == reconstructed.getPaintOptionsAndroid()) ;
40 } 40 }
41 DEFINE_TESTCLASS_SHORT(android_options_serialization);
42 41
43 static void android_options_serialization_reverse(skiatest::Reporter* reporter) { 42 DEF_TEST(AndroidOptionsSerializationReverse, reporter) {
44 // Opposite test of above: make sure the serialized default values of a pain t overwrite 43 // Opposite test of above: make sure the serialized default values of a pain t overwrite
45 // non-default values on the paint we're unflattening into. 44 // non-default values on the paint we're unflattening into.
46 const SkPaint defaultOptions; 45 const SkPaint defaultOptions;
47 46
48 SkPaintOptionsAndroid options; 47 SkPaintOptionsAndroid options;
49 options.setLanguage("ja-JP"); 48 options.setLanguage("ja-JP");
50 options.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant); 49 options.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant);
51 options.setUseFontFallbacks(true); 50 options.setUseFontFallbacks(true);
52 SkPaint nonDefaultOptions; 51 SkPaint nonDefaultOptions;
53 nonDefaultOptions.setPaintOptionsAndroid(options); 52 nonDefaultOptions.setPaintOptionsAndroid(options);
54 53
55 Reconstruct(defaultOptions, &nonDefaultOptions); 54 Reconstruct(defaultOptions, &nonDefaultOptions);
56 55
57 REPORTER_ASSERT(reporter, 56 REPORTER_ASSERT(reporter,
58 defaultOptions.getPaintOptionsAndroid() == 57 defaultOptions.getPaintOptionsAndroid() ==
59 nonDefaultOptions.getPaintOptionsAndroid()); 58 nonDefaultOptions.getPaintOptionsAndroid());
60 } 59 }
61 DEFINE_TESTCLASS_SHORT(android_options_serialization_reverse);
62 60
63 static void android_options_size(skiatest::Reporter* reporter) { 61 DEF_TEST(AndroidOptionsSize, reporter) {
64 // A paint with default android options should serialize to something smalle r than 62 // A paint with default android options should serialize to something smalle r than
65 // a paint with non-default android options. 63 // a paint with non-default android options.
66 64
67 SkPaint defaultOptions; 65 SkPaint defaultOptions;
68 66
69 SkPaintOptionsAndroid options; 67 SkPaintOptionsAndroid options;
70 options.setUseFontFallbacks(true); 68 options.setUseFontFallbacks(true);
71 SkPaint nonDefaultOptions; 69 SkPaint nonDefaultOptions;
72 nonDefaultOptions.setPaintOptionsAndroid(options); 70 nonDefaultOptions.setPaintOptionsAndroid(options);
73 71
74 SkPaint dummy; 72 SkPaint dummy;
75 73
76 REPORTER_ASSERT(reporter, 74 REPORTER_ASSERT(reporter,
77 Reconstruct(defaultOptions, &dummy) < Reconstruct(nonDefault Options, &dummy)); 75 Reconstruct(defaultOptions, &dummy) < Reconstruct(nonDefault Options, &dummy));
78 } 76 }
79 DEFINE_TESTCLASS_SHORT(android_options_size);
80 77
81 #endif // SK_BUILD_FOR_ANDROID 78 #endif // SK_BUILD_FOR_ANDROID
OLDNEW
« no previous file with comments | « no previous file | tests/PathOpsAngleTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698