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

Side by Side Diff: tests/AndroidPaintTest.cpp

Issue 134163010: Refactor read and write buffers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: original write flags were fine Created 6 years, 10 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
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 "SkOrderedReadBuffer.h" 4 #include "SkReadBuffer.h"
5 #include "SkOrderedWriteBuffer.h" 5 #include "SkWriteBuffer.h"
6 #include "SkPaint.h" 6 #include "SkPaint.h"
7 #include "SkPaintOptionsAndroid.h" 7 #include "SkPaintOptionsAndroid.h"
8 #include "Test.h" 8 #include "Test.h"
9 9
10 static size_t Reconstruct(const SkPaint& src, SkPaint* dst) { 10 static size_t Reconstruct(const SkPaint& src, SkPaint* dst) {
11 SkOrderedWriteBuffer writer; 11 SkWriteBuffer writer;
12 src.flatten(writer); 12 src.flatten(writer);
13 13
14 const size_t size = writer.bytesWritten(); 14 const size_t size = writer.bytesWritten();
15 SkAutoMalloc bytes(size); 15 SkAutoMalloc bytes(size);
16 writer.writeToMemory(bytes.get()); 16 writer.writeToMemory(bytes.get());
17 17
18 SkOrderedReadBuffer reader(bytes.get(), size); 18 SkReadBuffer reader(bytes.get(), size);
19 dst->unflatten(reader); 19 dst->unflatten(reader);
20 20
21 return size; 21 return size;
22 } 22 }
23 23
24 DEF_TEST(AndroidOptionsSerialization, reporter) { 24 DEF_TEST(AndroidOptionsSerialization, reporter) {
25 // We want to make sure that Android's paint options survive a flatten/unfla tten round trip. 25 // We want to make sure that Android's paint options survive a flatten/unfla tten round trip.
26 // These are all non-default options. 26 // These are all non-default options.
27 SkPaintOptionsAndroid options; 27 SkPaintOptionsAndroid options;
28 options.setLanguage("ja-JP"); 28 options.setLanguage("ja-JP");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 SkPaint nonDefaultOptions; 68 SkPaint nonDefaultOptions;
69 nonDefaultOptions.setPaintOptionsAndroid(options); 69 nonDefaultOptions.setPaintOptionsAndroid(options);
70 70
71 SkPaint dummy; 71 SkPaint dummy;
72 72
73 REPORTER_ASSERT(reporter, 73 REPORTER_ASSERT(reporter,
74 Reconstruct(defaultOptions, &dummy) < Reconstruct(nonDefault Options, &dummy)); 74 Reconstruct(defaultOptions, &dummy) < Reconstruct(nonDefault Options, &dummy));
75 } 75 }
76 76
77 #endif // SK_BUILD_FOR_ANDROID 77 #endif // SK_BUILD_FOR_ANDROID
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698