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

Side by Side Diff: tests/AndroidPaintTest.cpp

Issue 24075010: We don't flatten or unflatten SkPaintOptionsAndroid. Reproduce and fix. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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
« include/core/SkPicture.h ('K') | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #ifdef SK_BUILD_FOR_ANDROID
2
3 #include "SkPaintOptionsAndroid.h"
4 #include "SkOrderedReadBuffer.h"
5 #include "SkOrderedWriteBuffer.h"
6 #include "SkPaint.h"
7 #include "Test.h"
8 #include "TestClassDef.h"
9
10 static bool Equal(const SkPaintOptionsAndroid& a, const SkPaintOptionsAndroid& b ) {
11 return !(a != b);
12 }
13
14 static void android_cjk_serialization(skiatest::Reporter* r) {
15 // We want to make sure that Android's paint options survive a flatten/unfla tten round trip.
16 // These are all non-default options.
17 SkPaintOptionsAndroid options;
18 options.setLanguage("ja-JP");
19 options.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant);
20 options.setUseFontFallbacks(true);
21
22 SkPaint paint;
23 paint.setPaintOptionsAndroid(options);
24
25 // Flatten the paint.
26 SkOrderedWriteBuffer writer(64 /*arbitrary*/);
27 paint.flatten(writer);
28 const size_t size = writer.bytesWritten();
29 SkAutoMalloc bytes(size);
30 writer.writeToMemory(bytes.get());
31
32 // Unflatten the bytes into a new paint.
33 SkPaint reconstructed;
34 SkOrderedReadBuffer reader(bytes.get(), size);
35 reconstructed.unflatten(reader);
36
37 REPORTER_ASSERT(r, Equal(options, reconstructed.getPaintOptionsAndroid()));
38 }
39 DEFINE_TESTCLASS_SHORT(android_cjk_serialization);
40
41 #endif // SK_BUILD_FOR_ANDROID
OLDNEW
« include/core/SkPicture.h ('K') | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698