You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/03/27 03:39:42 UTC
spec commit: Tests for CB-389: resolveLocalFileSystemURI does not
work on a resized image captured from Camera.getPicture()
Updated Branches:
refs/heads/master 5f7ff8a7d -> 6bf737ecb
Tests for CB-389: resolveLocalFileSystemURI does not work on a resized image captured from Camera.getPicture()
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/6bf737ec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/6bf737ec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/6bf737ec
Branch: refs/heads/master
Commit: 6bf737ecb14b1489442ef685fd1f876e4d68a5c8
Parents: 5f7ff8a
Author: macdonst <si...@gmail.com>
Authored: Mon Mar 26 21:39:29 2012 -0400
Committer: macdonst <si...@gmail.com>
Committed: Mon Mar 26 21:39:29 2012 -0400
----------------------------------------------------------------------
autotest/tests/file.tests.js | 88 ++++++++++++++++++++++++++++++++++++-
1 files changed, 87 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/6bf737ec/autotest/tests/file.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/file.tests.js b/autotest/tests/file.tests.js
index 7be5645..a64f567 100644
--- a/autotest/tests/file.tests.js
+++ b/autotest/tests/file.tests.js
@@ -51,7 +51,49 @@ Tests.prototype.FileTests = function() {
equal(FileError.PATH_EXISTS_ERR, 12, "FileError.PATH_EXISTS_ERR should be defined");
});
- module('LocalFileSystem interface');
+ module('LocalFileSystem interface', {
+ // setup function will run before each test
+ setup: function() {
+ var that = this;
+ this.root = getFileSystemRoot();
+ this.fail = function(error) {
+ console.log('file error: ' + error.code);
+ };
+ this.unexpectedSuccess = function() {
+ console.log('!!! success function called when not expected !!!');
+ };
+ // deletes specified file or directory
+ this.deleteEntry = function(name, success, error) {
+ // deletes entry, if it exists
+ window.resolveLocalFileSystemURI(that.root.toURL() + '/' + name,
+ function(entry) {
+ console.log('Deleting: ' + entry.fullPath);
+ if (entry.isDirectory === true) {
+ entry.removeRecursively(success, error);
+ }
+ else {
+ entry.remove(success, error);
+ }
+ },
+ // doesn't exist
+ success);
+ };
+ // deletes and re-creates the specified file
+ this.createFile = function(fileName, success, error) {
+ that.deleteEntry(fileName, function() {
+ console.log('Creating file: ' + that.root.fullPath + '/' + fileName);
+ that.root.getFile(fileName, {create: true}, success, error);
+ }, error);
+ };
+ // deletes and re-creates the specified directory
+ this.createDirectory = function(dirName, success, error) {
+ that.deleteEntry(dirName, function() {
+ console.log('Creating directory: ' + that.root.fullPath + '/' + dirName);
+ that.root.getDirectory(dirName, {create: true}, success, error);
+ }, error);
+ };
+ }
+ });
test("window.requestFileSystem function should be defined", function() {
expect(1);
ok(typeof window.requestFileSystem === 'function', "window.requestFileSystem should be a function.");
@@ -127,6 +169,50 @@ Tests.prototype.FileTests = function() {
// Request the file system
window.requestFileSystem(-1, 0, null, failFS);
});
+ test("resolve valid file name", function() {
+ QUnit.stop(Tests.TEST_TIMEOUT);
+ expect(2);
+
+ var fileName = "resolve.file.uri",
+ that = this,
+ resolveCallback = function(entry) {
+ // lookup file system entry
+ window.resolveLocalFileSystemURI(entry.toURI(), testEntry, this.fail);
+ },
+ testEntry = function(fileEntry) {
+ ok(typeof fileEntry !== 'undefined' && fileEntry !== null, "fileEntry should not be null.");
+ ok(fileEntry.name == fileName, "fileEntry.name should equal 'resolve.file.uri'");
+
+ // cleanup
+ that.deleteEntry(fileName);
+ QUnit.start();
+ };
+
+ // create a new file entry
+ this.createFile(fileName, resolveCallback, this.fail);
+ });
+ test("resolve valid file name with parameters", function() {
+ QUnit.stop(Tests.TEST_TIMEOUT);
+ expect(2);
+
+ var fileName = "resolve.file.uri.params",
+ that = this,
+ resolveCallback = function(entry) {
+ // lookup file system entry
+ window.resolveLocalFileSystemURI(entry.toURI() + "?1234567890", testEntry, this.fail);
+ },
+ testEntry = function(fileEntry) {
+ ok(typeof fileEntry !== 'undefined' && fileEntry !== null, "fileEntry should not be null.");
+ ok(fileEntry.name == fileName, "fileEntry.name should equal 'resolve.file.uri.params'");
+
+ // cleanup
+ that.deleteEntry(fileName);
+ QUnit.start();
+ };
+
+ // create a new file entry
+ this.createFile(fileName, resolveCallback, this.fail);
+ });
test("resolve invalid file name", function() {
QUnit.stop(Tests.TEST_TIMEOUT);
expect(2);