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

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

Issue 8578003: Implement setPosition on File to seek to a byte position. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. 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_win.cc ('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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 input.openSync(); 267 input.openSync();
268 input.positionHandler = (position) { 268 input.positionHandler = (position) {
269 Expect.equals(0, position); 269 Expect.equals(0, position);
270 List<int> buffer = new List<int>(100); 270 List<int> buffer = new List<int>(100);
271 input.readListHandler = (bytes_read) { 271 input.readListHandler = (bytes_read) {
272 input.positionHandler = (position) { 272 input.positionHandler = (position) {
273 Expect.equals(12, position); 273 Expect.equals(12, position);
274 input.readListHandler = (bytes_read) { 274 input.readListHandler = (bytes_read) {
275 input.positionHandler = (position) { 275 input.positionHandler = (position) {
276 Expect.equals(18, position); 276 Expect.equals(18, position);
277 input.close(); 277 input.setPositionHandler = () {
278 input.positionHandler = (position) {
279 Expect.equals(8, position);
280 input.close();
281 };
282 input.position();
283 };
284 input.setPosition(8);
278 }; 285 };
279 }; 286 };
280 input.readList(buffer, 12, 6); 287 input.readList(buffer, 12, 6);
281 }; 288 };
282 input.position(); 289 input.position();
283 }; 290 };
284 input.readList(buffer, 0, 12); 291 input.readList(buffer, 0, 12);
285 }; 292 };
286 input.position(); 293 input.position();
287 return 1; 294 return 1;
288 } 295 }
289 296
290 static int testPositionSync() { 297 static int testPositionSync() {
291 String filename = getFilename("tests/vm/data/fixed_length_file"); 298 String filename = getFilename("tests/vm/data/fixed_length_file");
292 File input = new File(filename); 299 File input = new File(filename);
293 input.openSync(); 300 input.openSync();
294 Expect.equals(0, input.positionSync()); 301 Expect.equals(0, input.positionSync());
295 List<int> buffer = new List<int>(100); 302 List<int> buffer = new List<int>(100);
296 input.readListSync(buffer, 0, 12); 303 input.readListSync(buffer, 0, 12);
297 Expect.equals(12, input.positionSync()); 304 Expect.equals(12, input.positionSync());
298 input.readListSync(buffer, 12, 6); 305 input.readListSync(buffer, 12, 6);
299 Expect.equals(18, input.positionSync()); 306 Expect.equals(18, input.positionSync());
307 input.setPositionSync(8);
308 Expect.equals(8, input.positionSync());
300 input.closeSync(); 309 input.closeSync();
301 return 1; 310 return 1;
302 } 311 }
303 312
304 // Tests exception handling after file was closed. 313 // Tests exception handling after file was closed.
305 static int testCloseException() { 314 static int testCloseException() {
306 bool exceptionCaught = false; 315 bool exceptionCaught = false;
307 bool wrongExceptionCaught = false; 316 bool wrongExceptionCaught = false;
308 String filename = getFilename("tests/vm/data/fixed_length_file"); 317 String filename = getFilename("tests/vm/data/fixed_length_file");
309 File input = new File(filename + "_out"); 318 File input = new File(filename + "_out");
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 Expect.equals(1, testCloseException()); 572 Expect.equals(1, testCloseException());
564 Expect.equals(1, testCloseExceptionStream()); 573 Expect.equals(1, testCloseExceptionStream());
565 Expect.equals(1, testBufferOutOfBoundsException()); 574 Expect.equals(1, testBufferOutOfBoundsException());
566 Expect.equals(1, testMixedSyncAndAsync()); 575 Expect.equals(1, testMixedSyncAndAsync());
567 } 576 }
568 } 577 }
569 578
570 main() { 579 main() {
571 FileTest.testMain(); 580 FileTest.testMain();
572 } 581 }
OLDNEW
« no previous file with comments | « runtime/bin/file_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698