From 47f43de75d9d949db9a19ea919538117ec02f95b Mon Sep 17 00:00:00 2001 From: David Rajchenbach-Teller Date: Mon, 13 Aug 2012 21:54:43 -0400 Subject: [PATCH] Bug 780499 - Companion testsuite. r=froydnj --- .../tests/mochi/worker_test_osfile_front.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/toolkit/components/osfile/tests/mochi/worker_test_osfile_front.js b/toolkit/components/osfile/tests/mochi/worker_test_osfile_front.js index b455951065d..165f05421fc 100644 --- a/toolkit/components/osfile/tests/mochi/worker_test_osfile_front.js +++ b/toolkit/components/osfile/tests/mochi/worker_test_osfile_front.js @@ -20,6 +20,7 @@ self.onmessage = function onmessage_start(msg) { test_open_non_existing_file(); test_copy_existing_file(); test_read_write_file(); + test_position(); test_move_file(); test_iter_dir(); test_info(); @@ -294,6 +295,35 @@ function test_iter_dir() ok(true, "test_iter_dir: Complete"); } +function test_position() { + ok(true, "test_position: Starting"); + + ok("POS_START" in OS.File, "test_position: POS_START exists"); + ok("POS_CURRENT" in OS.File, "test_position: POS_CURRENT exists"); + ok("POS_END" in OS.File, "test_position: POS_END exists"); + + let ARBITRARY_POSITION = 321; + let src_file_name = "chrome/toolkit/components/osfile/tests/mochi/worker_test_osfile_unix.js"; + + + let file = OS.File.open(src_file_name); + is(file.getPosition(), 0, "test_position: Initial position is 0"); + + let size = 0 + file.stat().size; // Hack: We can remove this 0 + once 776259 has landed + + file.setPosition(ARBITRARY_POSITION, OS.File.POS_START); + is(file.getPosition(), ARBITRARY_POSITION, "test_position: Setting position from start"); + + file.setPosition(-ARBITRARY_POSITION, OS.File.POS_END); + is(file.getPosition(), size - ARBITRARY_POSITION, "test_position: Setting position from end"); + + file.setPosition(ARBITRARY_POSITION, OS.File.POS_CURRENT); + is(file.getPosition(), size, "test_position: Setting position from current"); + + file.close(); + ok(true, "test_position: Complete"); +} + function test_info() { ok(true, "test_info: Starting");