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 |