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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkFrontBufferedStream.h" | 10 #include "SkFrontBufferedStream.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 for (i = 0; i < SK_ARRAY_COUNT(sizes); ++i) { | 157 for (i = 0; i < SK_ARRAY_COUNT(sizes); ++i) { |
158 bool success = wstream.writePackedUInt(sizes[i]); | 158 bool success = wstream.writePackedUInt(sizes[i]); |
159 REPORTER_ASSERT(reporter, success); | 159 REPORTER_ASSERT(reporter, success); |
160 } | 160 } |
161 wstream.flush(); | 161 wstream.flush(); |
162 | 162 |
163 SkMemoryStream rstream(buffer, sizeof(buffer)); | 163 SkMemoryStream rstream(buffer, sizeof(buffer)); |
164 for (i = 0; i < SK_ARRAY_COUNT(sizes); ++i) { | 164 for (i = 0; i < SK_ARRAY_COUNT(sizes); ++i) { |
165 size_t n = rstream.readPackedUInt(); | 165 size_t n = rstream.readPackedUInt(); |
166 if (sizes[i] != n) { | 166 if (sizes[i] != n) { |
167 SkDebugf("-- %d: sizes:%x n:%x\n", i, sizes[i], n); | 167 ERRORF(reporter, "sizes:%x != n:%x\n", i, sizes[i], n); |
168 } | 168 } |
169 REPORTER_ASSERT(reporter, sizes[i] == n); | |
170 } | 169 } |
171 } | 170 } |
172 | 171 |
173 // Test that setting an SkMemoryStream to a nullptr data does not result in a cr
ash when calling | 172 // Test that setting an SkMemoryStream to a nullptr data does not result in a cr
ash when calling |
174 // methods that access fData. | 173 // methods that access fData. |
175 static void TestDereferencingData(SkMemoryStream* memStream) { | 174 static void TestDereferencingData(SkMemoryStream* memStream) { |
176 memStream->read(nullptr, 0); | 175 memStream->read(nullptr, 0); |
177 memStream->getMemoryBase(); | 176 memStream->getMemoryBase(); |
178 SkAutoDataUnref data(memStream->copyToData()); | 177 SkAutoDataUnref data(memStream->copyToData()); |
179 } | 178 } |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 SkMemoryStream smartStream(src.get(), (size_t)N); | 428 SkMemoryStream smartStream(src.get(), (size_t)N); |
430 stream_copy_test(reporter, src, N, &smartStream); | 429 stream_copy_test(reporter, src, N, &smartStream); |
431 } | 430 } |
432 | 431 |
433 DEF_TEST(StreamEmptyStreamMemoryBase, r) { | 432 DEF_TEST(StreamEmptyStreamMemoryBase, r) { |
434 SkDynamicMemoryWStream tmp; | 433 SkDynamicMemoryWStream tmp; |
435 SkAutoTDelete<SkStreamAsset> asset(tmp.detachAsStream()); | 434 SkAutoTDelete<SkStreamAsset> asset(tmp.detachAsStream()); |
436 REPORTER_ASSERT(r, nullptr == asset->getMemoryBase()); | 435 REPORTER_ASSERT(r, nullptr == asset->getMemoryBase()); |
437 } | 436 } |
438 | 437 |
OLD | NEW |