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

Side by Side Diff: tests/StreamTest.cpp

Issue 16098011: Fix bug in setting directories for tests. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « tests/OSPathTest.cpp ('k') | tests/Test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "Test.h" 8 #include "Test.h"
9 #include "SkRandom.h" 9 #include "SkRandom.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
(...skipping 17 matching lines...) Expand all
28 REPORTER_ASSERT(reporter, bytes == len); 28 REPORTER_ASSERT(reporter, bytes == len);
29 REPORTER_ASSERT(reporter, !memcmp(tmp, src, len)); 29 REPORTER_ASSERT(reporter, !memcmp(tmp, src, len));
30 } 30 }
31 31
32 // expect EOF 32 // expect EOF
33 size_t bytes = stream->read(tmp, 1); 33 size_t bytes = stream->read(tmp, 1);
34 REPORTER_ASSERT(reporter, 0 == bytes); 34 REPORTER_ASSERT(reporter, 0 == bytes);
35 } 35 }
36 36
37 static void test_filestreams(skiatest::Reporter* reporter, const char* tmpDir) { 37 static void test_filestreams(skiatest::Reporter* reporter, const char* tmpDir) {
38 SkString path; 38 SkString path = SkOSPath::SkPathJoin(tmpDir, "wstream_test");
39 path.printf("%s%s", tmpDir, "wstream_test");
40 39
41 const char s[] = "abcdefghijklmnopqrstuvwxyz"; 40 const char s[] = "abcdefghijklmnopqrstuvwxyz";
42 41
43 { 42 {
44 SkFILEWStream writer(path.c_str()); 43 SkFILEWStream writer(path.c_str());
45 if (!writer.isValid()) { 44 if (!writer.isValid()) {
46 SkString msg; 45 SkString msg;
47 msg.printf("Failed to create tmp file %s\n", path.c_str()); 46 msg.printf("Failed to create tmp file %s\n", path.c_str());
48 reporter->reportFailed(msg.c_str()); 47 reporter->reportFailed(msg.c_str());
49 return; 48 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 90 }
92 91
93 { 92 {
94 SkData* data = ds.copyToData(); 93 SkData* data = ds.copyToData();
95 REPORTER_ASSERT(reporter, 100 * 26 == data->size()); 94 REPORTER_ASSERT(reporter, 100 * 26 == data->size());
96 REPORTER_ASSERT(reporter, memcmp(dst, data->data(), data->size()) == 0); 95 REPORTER_ASSERT(reporter, memcmp(dst, data->data(), data->size()) == 0);
97 data->unref(); 96 data->unref();
98 } 97 }
99 delete[] dst; 98 delete[] dst;
100 99
101 if (!skiatest::Test::GetTmpDir().isEmpty()) { 100 SkString tmpDir = skiatest::Test::GetTmpDir();
102 test_filestreams(reporter, skiatest::Test::GetTmpDir().c_str()); 101 if (!tmpDir.isEmpty()) {
102 test_filestreams(reporter, tmpDir.c_str());
103 } 103 }
104 } 104 }
105 105
106 static void TestPackedUInt(skiatest::Reporter* reporter) { 106 static void TestPackedUInt(skiatest::Reporter* reporter) {
107 // we know that packeduint tries to write 1, 2 or 4 bytes for the length, 107 // we know that packeduint tries to write 1, 2 or 4 bytes for the length,
108 // so we test values around each of those transitions (and a few others) 108 // so we test values around each of those transitions (and a few others)
109 const size_t sizes[] = { 109 const size_t sizes[] = {
110 0, 1, 2, 0xFC, 0xFD, 0xFE, 0xFF, 0x100, 0x101, 32767, 32768, 32769, 110 0, 1, 2, 0xFC, 0xFD, 0xFE, 0xFF, 0x100, 0x101, 32767, 32768, 32769,
111 0xFFFD, 0xFFFE, 0xFFFF, 0x10000, 0x10001, 111 0xFFFD, 0xFFFE, 0xFFFF, 0x10000, 0x10001,
112 0xFFFFFD, 0xFFFFFE, 0xFFFFFF, 0x1000000, 0x1000001, 112 0xFFFFFD, 0xFFFFFE, 0xFFFFFF, 0x1000000, 0x1000001,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 154
155 static void TestStreams(skiatest::Reporter* reporter) { 155 static void TestStreams(skiatest::Reporter* reporter) {
156 TestWStream(reporter); 156 TestWStream(reporter);
157 TestPackedUInt(reporter); 157 TestPackedUInt(reporter);
158 TestNullData(); 158 TestNullData();
159 } 159 }
160 160
161 #include "TestClassDef.h" 161 #include "TestClassDef.h"
162 DEFINE_TESTCLASS("Stream", StreamTestClass, TestStreams) 162 DEFINE_TESTCLASS("Stream", StreamTestClass, TestStreams)
OLDNEW
« no previous file with comments | « tests/OSPathTest.cpp ('k') | tests/Test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698