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

Side by Side Diff: tests/standalone/src/FileTest.dart

Issue 8439067: Implement fullPath method on File objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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 | « runtime/bin/file_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Dart test program for testing file I/O. 5 // Dart test program for testing file I/O.
6 6
7 7
8 class FileTest { 8 class FileTest {
9 // Test for file read functionality. 9 // Test for file read functionality.
10 static int testReadStream() { 10 static int testReadStream() {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 Expect.equals(42, bytes_read); 137 Expect.equals(42, bytes_read);
138 file.closeHandler = () { 138 file.closeHandler = () {
139 // Write the contents of the file just read into another file. 139 // Write the contents of the file just read into another file.
140 String outFilenameBase = 140 String outFilenameBase =
141 getFilename("tests/vm/data/fixed_length_file"); 141 getFilename("tests/vm/data/fixed_length_file");
142 file = new File(outFilenameBase + "_out"); 142 file = new File(outFilenameBase + "_out");
143 file.errorHandler = (s) { 143 file.errorHandler = (s) {
144 Expect.fail("No errors expected"); 144 Expect.fail("No errors expected");
145 }; 145 };
146 file.createHandler = () { 146 file.createHandler = () {
147 file.openHandler = () { 147 file.fullPathHandler = (s) {
Søren Gjesse 2011/11/03 08:07:53 Maybe check that s is not just outFilenameBase + "
Mads Ager (google) 2011/11/03 10:18:26 Done.
148 file.noPendingWriteHandler = () { 148 Expect.isTrue(new File(s).existsSync());
149 file.closeHandler = () { 149 file.openHandler = () {
150 // Now read the contents of the file just written. 150 file.noPendingWriteHandler = () {
151 List<int> buffer2 = new List<int>(bytes_read); 151 file.closeHandler = () {
152 file = new File(getFilename(outFilenameBase)); 152 // Now read the contents of the file just written.
153 file.errorHandler = (s) { 153 List<int> buffer2 = new List<int>(bytes_read);
154 Expect.fail("No errors expected"); 154 file = new File(getFilename(outFilenameBase));
155 file.errorHandler = (s) {
156 Expect.fail("No errors expected");
157 };
158 file.openHandler = () {
159 file.readListHandler = (bytes_read) {
160 Expect.equals(42, bytes_read);
161 file.closeHandler = () {
162 // Now compare the two buffers to check if they
163 // are identical.
164 Expect.equals(buffer1.length, buffer2.length);
165 for (int i = 0; i < buffer1.length; i++) {
166 Expect.equals(buffer1[i], buffer2[i]);
167 }
168 };
169 file.close();
170 };
171 file.readList(buffer2, 0, 42);
172 };
173 file.open();
155 }; 174 };
156 file.openHandler = () { 175 file.close();
157 file.readListHandler = (bytes_read) {
158 Expect.equals(42, bytes_read);
159 file.closeHandler = () {
160 // Now compare the two buffers to check if they
161 // are identical.
162 Expect.equals(buffer1.length, buffer2.length);
163 for (int i = 0; i < buffer1.length; i++) {
164 Expect.equals(buffer1[i], buffer2[i]);
165 }
166 };
167 file.close();
168 };
169 file.readList(buffer2, 0, 42);
170 };
171 file.open();
172 }; 176 };
173 file.close(); 177 file.writeList(buffer1, 0, bytes_read);
174 }; 178 };
175 file.writeList(buffer1, 0, bytes_read); 179 file.open(true);
176 }; 180 };
177 file.open(true); 181 file.fullPath();
178 }; 182 };
179 file.create(); 183 file.create();
180 }; 184 };
181 file.close(); 185 file.close();
182 }; 186 };
183 file.readList(buffer1, 0, 42); 187 file.readList(buffer1, 0, 42);
184 }; 188 };
185 file.open(); 189 file.open();
186 return 1; 190 return 1;
187 191
188 } 192 }
189 193
190 static int testReadWriteSync() { 194 static int testReadWriteSync() {
191 // Read a file. 195 // Read a file.
192 String inFilename = getFilename("tests/vm/data/fixed_length_file"); 196 String inFilename = getFilename("tests/vm/data/fixed_length_file");
193 File file = new File(inFilename); 197 File file = new File(inFilename);
194 file.openSync(); 198 file.openSync();
195 List<int> buffer1 = new List<int>(42); 199 List<int> buffer1 = new List<int>(42);
196 int bytes_read = 0; 200 int bytes_read = 0;
197 int bytes_written = 0; 201 int bytes_written = 0;
198 bytes_read = file.readListSync(buffer1, 0, 42); 202 bytes_read = file.readListSync(buffer1, 0, 42);
199 Expect.equals(42, bytes_read); 203 Expect.equals(42, bytes_read);
200 file.closeSync(); 204 file.closeSync();
201 // Write the contents of the file just read into another file. 205 // Write the contents of the file just read into another file.
202 String outFilenameBase = getFilename("tests/vm/data/fixed_length_file"); 206 String outFilenameBase = getFilename("tests/vm/data/fixed_length_file");
203 file = new File(outFilenameBase + "_out"); 207 file = new File(outFilenameBase + "_out");
204 file.createSync(); 208 file.createSync();
209 String path = file.fullPathSync();
210 Expect.isTrue(new File(path).existsSync());
Søren Gjesse 2011/11/03 08:07:53 Ditto.
Mads Ager (google) 2011/11/03 10:18:26 Done.
205 file.openSync(true); 211 file.openSync(true);
206 file.writeListSync(buffer1, 0, bytes_read); 212 file.writeListSync(buffer1, 0, bytes_read);
207 file.closeSync(); 213 file.closeSync();
208 // Now read the contents of the file just written. 214 // Now read the contents of the file just written.
209 List<int> buffer2 = new List<int>(bytes_read); 215 List<int> buffer2 = new List<int>(bytes_read);
210 file = new File(getFilename(outFilenameBase)); 216 file = new File(getFilename(outFilenameBase));
211 file.openSync(); 217 file.openSync();
212 bytes_read = file.readListSync(buffer2, 0, 42); 218 bytes_read = file.readListSync(buffer2, 0, 42);
213 Expect.equals(42, bytes_read); 219 Expect.equals(42, bytes_read);
214 file.closeSync(); 220 file.closeSync();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 Expect.equals(1, testCloseException()); 557 Expect.equals(1, testCloseException());
552 Expect.equals(1, testCloseExceptionStream()); 558 Expect.equals(1, testCloseExceptionStream());
553 Expect.equals(1, testBufferOutOfBoundsException()); 559 Expect.equals(1, testBufferOutOfBoundsException());
554 Expect.equals(1, testMixedSyncAndAsync()); 560 Expect.equals(1, testMixedSyncAndAsync());
555 } 561 }
556 } 562 }
557 563
558 main() { 564 main() {
559 FileTest.testMain(); 565 FileTest.testMain();
560 } 566 }
OLDNEW
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698