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 "Test.h" | 8 #include "Test.h" |
9 #include "TestClassDef.h" | 9 #include "TestClassDef.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (tmpDir.isEmpty()) { | 179 if (tmpDir.isEmpty()) { |
180 return; | 180 return; |
181 } | 181 } |
182 | 182 |
183 SkString path = SkOSPath::SkPathJoin(tmpDir.c_str(), "data_test"); | 183 SkString path = SkOSPath::SkPathJoin(tmpDir.c_str(), "data_test"); |
184 | 184 |
185 const char s[] = "abcdefghijklmnopqrstuvwxyz"; | 185 const char s[] = "abcdefghijklmnopqrstuvwxyz"; |
186 { | 186 { |
187 SkFILEWStream writer(path.c_str()); | 187 SkFILEWStream writer(path.c_str()); |
188 if (!writer.isValid()) { | 188 if (!writer.isValid()) { |
189 SkString msg; | 189 ERRORF(reporter, "Failed to create tmp file %s\n", path.c_str()); |
190 msg.printf("Failed to create tmp file %s\n", path.c_str()); | |
191 reporter->reportFailed(msg); | |
192 return; | 190 return; |
193 } | 191 } |
194 writer.write(s, 26); | 192 writer.write(s, 26); |
195 } | 193 } |
196 | 194 |
197 SkFILE* file = sk_fopen(path.c_str(), kRead_SkFILE_Flag); | 195 SkFILE* file = sk_fopen(path.c_str(), kRead_SkFILE_Flag); |
198 SkAutoTUnref<SkData> r1(SkData::NewFromFILE(file)); | 196 SkAutoTUnref<SkData> r1(SkData::NewFromFILE(file)); |
199 REPORTER_ASSERT(reporter, r1.get() != NULL); | 197 REPORTER_ASSERT(reporter, r1.get() != NULL); |
200 REPORTER_ASSERT(reporter, r1->size() == 26); | 198 REPORTER_ASSERT(reporter, r1->size() == 26); |
201 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 2
6) == 0); | 199 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 2
6) == 0); |
(...skipping 26 matching lines...) Expand all Loading... |
228 SkData* tmp = SkData::NewSubset(r1, strlen(str), 10); | 226 SkData* tmp = SkData::NewSubset(r1, strlen(str), 10); |
229 assert_len(reporter, tmp, 0); | 227 assert_len(reporter, tmp, 0); |
230 tmp->unref(); | 228 tmp->unref(); |
231 tmp = SkData::NewSubset(r1, 0, 0); | 229 tmp = SkData::NewSubset(r1, 0, 0); |
232 assert_len(reporter, tmp, 0); | 230 assert_len(reporter, tmp, 0); |
233 tmp->unref(); | 231 tmp->unref(); |
234 | 232 |
235 test_cstring(reporter); | 233 test_cstring(reporter); |
236 test_files(reporter); | 234 test_files(reporter); |
237 } | 235 } |
OLD | NEW |