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

Unified Diff: tests/DataRefTest.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 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
Index: tests/DataRefTest.cpp
diff --git a/tests/DataRefTest.cpp b/tests/DataRefTest.cpp
index 03f66c5b04c5baf26340a7a18a13e60874769218..59b56fb362c4b24bed884cdd1b39d9fb91221f78 100644
--- a/tests/DataRefTest.cpp
+++ b/tests/DataRefTest.cpp
@@ -149,11 +149,11 @@ static void delete_int_proc(const void* ptr, void* context) {
delete[] data;
}
-static void assert_len(skiatest::Reporter* reporter, SkData* ref, size_t len) {
+static void assert_len(skiatest::Reporter* reporter, const sk_sp<SkData>& ref, size_t len) {
REPORTER_ASSERT(reporter, ref->size() == len);
}
-static void assert_data(skiatest::Reporter* reporter, SkData* ref,
+static void assert_data(skiatest::Reporter* reporter, const sk_sp<SkData>& ref,
const void* data, size_t len) {
REPORTER_ASSERT(reporter, ref->size() == len);
REPORTER_ASSERT(reporter, !memcmp(ref->data(), data, len));
@@ -163,12 +163,12 @@ static void test_cstring(skiatest::Reporter* reporter) {
const char str[] = "Hello world";
size_t len = strlen(str);
- SkAutoTUnref<SkData> r0(SkData::NewWithCopy(str, len + 1));
- SkAutoTUnref<SkData> r1(SkData::NewWithCString(str));
+ sk_sp<SkData> r0(SkData::MakeWithCopy(str, len + 1));
+ sk_sp<SkData> r1(SkData::MakeWithCString(str));
- REPORTER_ASSERT(reporter, r0->equals(r1));
+ REPORTER_ASSERT(reporter, r0->equals(r1.get()));
- SkAutoTUnref<SkData> r2(SkData::NewWithCString(nullptr));
+ sk_sp<SkData> r2(SkData::MakeWithCString(nullptr));
REPORTER_ASSERT(reporter, 1 == r2->size());
REPORTER_ASSERT(reporter, 0 == *r2->bytes());
}
@@ -192,13 +192,13 @@ static void test_files(skiatest::Reporter* reporter) {
}
FILE* file = sk_fopen(path.c_str(), kRead_SkFILE_Flag);
- SkAutoTUnref<SkData> r1(SkData::NewFromFILE(file));
+ sk_sp<SkData> r1(SkData::MakeFromFILE(file));
REPORTER_ASSERT(reporter, r1.get() != nullptr);
REPORTER_ASSERT(reporter, r1->size() == 26);
REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 26) == 0);
int fd = sk_fileno(file);
- SkAutoTUnref<SkData> r2(SkData::NewFromFD(fd));
+ sk_sp<SkData> r2(SkData::MakeFromFD(fd));
REPORTER_ASSERT(reporter, r2.get() != nullptr);
REPORTER_ASSERT(reporter, r2->size() == 26);
REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r2->data()), s, 26) == 0);
@@ -208,11 +208,10 @@ DEF_TEST(Data, reporter) {
const char* str = "We the people, in order to form a more perfect union.";
const int N = 10;
- SkAutoTUnref<SkData> r0(SkData::NewEmpty());
- SkAutoTUnref<SkData> r1(SkData::NewWithCopy(str, strlen(str)));
- SkAutoTUnref<SkData> r2(SkData::NewWithProc(new int[N], N*sizeof(int),
- delete_int_proc, gGlobal));
- SkAutoTUnref<SkData> r3(SkData::NewSubset(r1, 7, 6));
+ sk_sp<SkData> r0(SkData::MakeEmpty());
+ sk_sp<SkData> r1(SkData::MakeWithCopy(str, strlen(str)));
+ sk_sp<SkData> r2(SkData::MakeWithProc(new int[N], N*sizeof(int), delete_int_proc, gGlobal));
+ sk_sp<SkData> r3(SkData::MakeSubset(r1.get(), 7, 6));
assert_len(reporter, r0, 0);
assert_len(reporter, r1, strlen(str));
@@ -222,12 +221,10 @@ DEF_TEST(Data, reporter) {
assert_data(reporter, r1, str, strlen(str));
assert_data(reporter, r3, "people", 6);
- SkData* tmp = SkData::NewSubset(r1, strlen(str), 10);
+ sk_sp<SkData> tmp(SkData::MakeSubset(r1.get(), strlen(str), 10));
assert_len(reporter, tmp, 0);
- tmp->unref();
- tmp = SkData::NewSubset(r1, 0, 0);
+ tmp = SkData::MakeSubset(r1.get(), 0, 0);
assert_len(reporter, tmp, 0);
- tmp->unref();
test_cstring(reporter);
test_files(reporter);
« include/core/SkData.h ('K') | « tests/CodecTest.cpp ('k') | tests/ImageGeneratorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698