You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2012/04/05 23:20:42 UTC
spec commit: Fix CB-448 update non-ascii append file test
Updated Branches:
refs/heads/master 9e22aa268 -> db377f9f2
Fix CB-448 update non-ascii append file test
Update the non-ascii file write and append test to read back
written/appended data and compare that result and length
to initial JavaScript length rather than comparing written length.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/db377f9f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/db377f9f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/db377f9f
Branch: refs/heads/master
Commit: db377f9f2b4c5507b6eb1fcb8eb4fa029030cdef
Parents: 9e22aa2
Author: Becky Gibson <be...@apache.org>
Authored: Thu Apr 5 14:41:39 2012 -0400
Committer: Becky Gibson <be...@apache.org>
Committed: Thu Apr 5 17:19:41 2012 -0400
----------------------------------------------------------------------
autotest/tests/file.tests.js | 25 ++++++++++++++++---------
1 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/db377f9f/autotest/tests/file.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/file.tests.js b/autotest/tests/file.tests.js
index 2370fa5..4a0fd30 100644
--- a/autotest/tests/file.tests.js
+++ b/autotest/tests/file.tests.js
@@ -2503,7 +2503,7 @@ Tests.prototype.FileTests = function() {
});
test("should be able to write and append to file in Chinese Traditional, createWriter", function() {
QUnit.stop(Tests.TEST_TIMEOUT);
- expect(4);
+ expect(2);
var that = this,
fileName = "writer.append",
@@ -2516,8 +2516,8 @@ Tests.prototype.FileTests = function() {
write_file = function(fileEntry) {
fileEntry.createWriter(function(writer) {
writer.onwriteend = function(evt) {
- ok(writer.length === length, "should have written " + length + " bytes");
- ok(writer.position === length, "position should be at " + length);
+ // valid writing of non-ascii file was already validated in previous test.
+ // Append to file to verify writer.length and writer.position are set correctly
append_file(writer);
};
writer.write(rule);
@@ -2527,12 +2527,19 @@ Tests.prototype.FileTests = function() {
append_file = function(writer) {
var exception = " 除了這一個";
writer.onwriteend = function(evt) {
- ok(writer.length === length, "file length should be " + length);
- ok(writer.position === length, "position should be at " + length);
-
- // cleanup
- that.deleteFile(fileName);
- QUnit.start();
+ // read back file to verify that data was appended
+ var reader = new FileReader();
+ reader.onloadend = function(evt) {
+ console.log(evt.target.result);
+ ok(evt.target.result === (rule + exception), "reader.result after append should be equal to the text written.");
+ ok(evt.target.result.length === length, "reader.result length should equal initial length.");
+ // cleanup
+ that.deleteFile(fileName);
+ QUnit.start();
+ };
+ var myFile = new File();
+ myFile.fullPath = filePath;
+ reader.readAsText(myFile);
};
length += exception.length;
writer.seek(writer.length);