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

Unified 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 side-by-side diff with in-line comments
Download patch
« include/core/SkPicture.h ('K') | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/AndroidPaintTest.cpp
diff --git a/tests/AndroidPaintTest.cpp b/tests/AndroidPaintTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e318e27a811a1b10009bcce1cd6876f329598899
--- /dev/null
+++ b/tests/AndroidPaintTest.cpp
@@ -0,0 +1,41 @@
+#ifdef SK_BUILD_FOR_ANDROID
+
+#include "SkPaintOptionsAndroid.h"
+#include "SkOrderedReadBuffer.h"
+#include "SkOrderedWriteBuffer.h"
+#include "SkPaint.h"
+#include "Test.h"
+#include "TestClassDef.h"
+
+static bool Equal(const SkPaintOptionsAndroid& a, const SkPaintOptionsAndroid& b) {
+ return !(a != b);
+}
+
+static void android_cjk_serialization(skiatest::Reporter* r) {
+ // We want to make sure that Android's paint options survive a flatten/unflatten round trip.
+ // These are all non-default options.
+ SkPaintOptionsAndroid options;
+ options.setLanguage("ja-JP");
+ options.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant);
+ options.setUseFontFallbacks(true);
+
+ SkPaint paint;
+ paint.setPaintOptionsAndroid(options);
+
+ // Flatten the paint.
+ SkOrderedWriteBuffer writer(64 /*arbitrary*/);
+ paint.flatten(writer);
+ const size_t size = writer.bytesWritten();
+ SkAutoMalloc bytes(size);
+ writer.writeToMemory(bytes.get());
+
+ // Unflatten the bytes into a new paint.
+ SkPaint reconstructed;
+ SkOrderedReadBuffer reader(bytes.get(), size);
+ reconstructed.unflatten(reader);
+
+ REPORTER_ASSERT(r, Equal(options, reconstructed.getPaintOptionsAndroid()));
+}
+DEFINE_TESTCLASS_SHORT(android_cjk_serialization);
+
+#endif // SK_BUILD_FOR_ANDROID
« 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