OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkData.h" | 8 #include "SkData.h" |
9 #include "SkDataTable.h" | 9 #include "SkDataTable.h" |
10 #include "SkOSFile.h" | 10 #include "SkOSFile.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 const char s[] = "abcdefghijklmnopqrstuvwxyz"; | 184 const char s[] = "abcdefghijklmnopqrstuvwxyz"; |
185 { | 185 { |
186 SkFILEWStream writer(path.c_str()); | 186 SkFILEWStream writer(path.c_str()); |
187 if (!writer.isValid()) { | 187 if (!writer.isValid()) { |
188 ERRORF(reporter, "Failed to create tmp file %s\n", path.c_str()); | 188 ERRORF(reporter, "Failed to create tmp file %s\n", path.c_str()); |
189 return; | 189 return; |
190 } | 190 } |
191 writer.write(s, 26); | 191 writer.write(s, 26); |
192 } | 192 } |
193 | 193 |
194 SkFILE* file = sk_fopen(path.c_str(), kRead_SkFILE_Flag); | 194 FILE* file = sk_fopen(path.c_str(), kRead_SkFILE_Flag); |
195 SkAutoTUnref<SkData> r1(SkData::NewFromFILE(file)); | 195 SkAutoTUnref<SkData> r1(SkData::NewFromFILE(file)); |
196 REPORTER_ASSERT(reporter, r1.get() != nullptr); | 196 REPORTER_ASSERT(reporter, r1.get() != nullptr); |
197 REPORTER_ASSERT(reporter, r1->size() == 26); | 197 REPORTER_ASSERT(reporter, r1->size() == 26); |
198 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 2
6) == 0); | 198 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 2
6) == 0); |
199 | 199 |
200 int fd = sk_fileno(file); | 200 int fd = sk_fileno(file); |
201 SkAutoTUnref<SkData> r2(SkData::NewFromFD(fd)); | 201 SkAutoTUnref<SkData> r2(SkData::NewFromFD(fd)); |
202 REPORTER_ASSERT(reporter, r2.get() != nullptr); | 202 REPORTER_ASSERT(reporter, r2.get() != nullptr); |
203 REPORTER_ASSERT(reporter, r2->size() == 26); | 203 REPORTER_ASSERT(reporter, r2->size() == 26); |
204 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r2->data()), s, 2
6) == 0); | 204 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r2->data()), s, 2
6) == 0); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 } | 306 } |
307 | 307 |
308 for (int i = 0; i < N; ++i) { | 308 for (int i = 0; i < N; ++i) { |
309 REPORTER_ASSERT(reporter, (i + 1) * 26U == readers[i]->size()); | 309 REPORTER_ASSERT(reporter, (i + 1) * 26U == readers[i]->size()); |
310 check_alphabet_buffer(reporter, readers[i]); | 310 check_alphabet_buffer(reporter, readers[i]); |
311 check_alphabet_stream(reporter, streams[i]); | 311 check_alphabet_stream(reporter, streams[i]); |
312 readers[i]->unref(); | 312 readers[i]->unref(); |
313 delete streams[i]; | 313 delete streams[i]; |
314 } | 314 } |
315 } | 315 } |
OLD | NEW |