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/04/18 19:54:35 UTC
spec commit: Tests for CB-539: FileTransfer.download fails when
target starts with 'file://'
Updated Branches:
refs/heads/master bfe48ce6c -> 7125e7256
Tests for CB-539: FileTransfer.download fails when target starts with 'file://'
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/7125e725
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/7125e725
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/7125e725
Branch: refs/heads/master
Commit: 7125e7256e59377fb3ec376b367d8f2169267c4f
Parents: bfe48ce
Author: macdonst <si...@gmail.com>
Authored: Wed Apr 18 13:53:22 2012 -0400
Committer: macdonst <si...@gmail.com>
Committed: Wed Apr 18 13:53:22 2012 -0400
----------------------------------------------------------------------
autotest/index.html | 1 +
autotest/pages/all.html | 1 +
autotest/pages/filetransfer.html | 54 +++++++++++++++++++++++++++++
autotest/tests/filetransfer.tests.js | 44 +++++++++++++++++++++++
4 files changed, 100 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/7125e725/autotest/index.html
----------------------------------------------------------------------
diff --git a/autotest/index.html b/autotest/index.html
index 5850c50..5018d07 100755
--- a/autotest/index.html
+++ b/autotest/index.html
@@ -21,6 +21,7 @@
<a href="pages/contacts.html" class="btn large" style="width:100%;">Run Contacts Tests</a>
<a href="pages/device.html" class="btn large" style="width:100%;">Run Device Tests</a>
<a href="pages/file.html" class="btn large" style="width:100%;">Run File Tests</a>
+ <a href="pages/filetransfer.html" class="btn large" style="width:100%;">Run FileTransfer Tests</a>
<a href="pages/geolocation.html" class="btn large" style="width:100%;">Run Geolocation Tests</a>
<a href="pages/media.html" class="btn large" style="width:100%;">Run Media Tests</a>
<a href="pages/network.html" class="btn large" style="width:100%;">Run Network Tests</a>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/7125e725/autotest/pages/all.html
----------------------------------------------------------------------
diff --git a/autotest/pages/all.html b/autotest/pages/all.html
index 6b045ab..23e8244 100644
--- a/autotest/pages/all.html
+++ b/autotest/pages/all.html
@@ -25,6 +25,7 @@
<script type="text/javascript" src="../tests/camera.tests.js"></script>
<script type="text/javascript" src="../tests/device.tests.js"></script>
<script type="text/javascript" src="../tests/file.tests.js"></script>
+ <script type="text/javascript" src="../tests/filetransfer.tests.js"></script>
<script type="text/javascript" src="../tests/geolocation.tests.js"></script>
<script type="text/javascript" src="../tests/media.tests.js"></script>
<script type="text/javascript" src="../tests/network.tests.js"></script>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/7125e725/autotest/pages/filetransfer.html
----------------------------------------------------------------------
diff --git a/autotest/pages/filetransfer.html b/autotest/pages/filetransfer.html
new file mode 100644
index 0000000..f305a66
--- /dev/null
+++ b/autotest/pages/filetransfer.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
+ <meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes, initial-scale=1.0;" />
+
+ <title>Cordova: FileTransfer API Specs</title>
+
+ <!-- Load QUnit -->
+ <link rel="stylesheet" type="text/css" href="../qunit.css" />
+ <script type="text/javascript" src="../qunit.js"></script>
+
+ <!-- Source -->
+ <script type="text/javascript" src="../../phonegap.js"></script>
+
+ <!-- Load Test Runner -->
+ <script type="text/javascript" src="../test-runner.js"></script>
+
+ <!-- Tests -->
+ <script type="text/javascript" src="../tests/filetransfer.tests.js"></script>
+ <script type="text/javascript">
+ document.addEventListener('deviceready', function() {
+ console.log('running tests');
+ var tests = new Tests();
+
+ // Each group of tests are declared as a function in the object `Tests`.
+ // A group of tests are identified by a name that contains the word 'Tests'.
+ //
+ // Load each group of tests into QUnit
+ for (var t in tests) {
+ if (t.indexOf('Tests') > -1) {
+ tests[t]();
+ }
+ }
+
+ // Start the QUnit test suite
+ QUnit.start();
+ }, false);
+ </script>
+ </head>
+ <body>
+ <div class="backBtn" onclick="backHome();">Back</div>
+ <h1 id="qunit-header">Cordova: File Transfer API Specs</h1>
+ <h2 id="qunit-banner"></h2>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-fixture">
+ <!-- Populated by tests -->
+ </div>
+ </body>
+</html>
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/7125e725/autotest/tests/filetransfer.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/filetransfer.tests.js b/autotest/tests/filetransfer.tests.js
new file mode 100644
index 0000000..855019f
--- /dev/null
+++ b/autotest/tests/filetransfer.tests.js
@@ -0,0 +1,44 @@
+Tests.prototype.FileTransferTests = function() {
+ module('FileTransfer');
+ test("should exist", function() {
+ expect(1);
+ var ft = new FileTransfer();
+ ok(ft !== null, "FileTransfer should not be null.");
+ });
+ test("should contain proper function", function() {
+ expect(4);
+ var ft = new FileTransfer();
+ ok(typeof ft.upload != 'undefined' && ft.upload !== null, "FileTransfer.upload should not be null.");
+ ok(typeof ft.upload == 'function', "FileTransfer.upload should be a function.");
+ ok(typeof ft.download != 'undefined' && ft.download !== null, "FileTransfer.download should not be null.");
+ ok(typeof ft.download == 'function', "FileTransfer.download should be a function.");
+ });
+ module('FileTransferError interface');
+ test("FileTransferError constants should be defined", function() {
+ expect(3);
+ equal(FileTransferError.FILE_NOT_FOUND_ERR, 1, "FileTransferError.FILE_NOT_FOUND_ERR should be defined");
+ equal(FileTransferError.INVALID_URL_ERR, 2, "FileTransferError.INVALID_URL_ERR should be defined");
+ equal(FileTransferError.CONNECTION_ERR, 3, "FileTransferError.CONNECTION_ERR should be defined");
+ });
+ module('FileTransfer.download');
+ test("should be able to download a file", function() {
+ expect(1);
+ QUnit.stop(Tests.TEST_TIMEOUT);
+ var fail = function(error) {
+ ok(false, "This test failed, check to see if you whitelisted 'ajax.googleapis.com'");
+ QUnit.start();
+ };
+ var remoteFile = "https://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js";
+ var localFileName = remoteFile.substring(remoteFile.lastIndexOf('/')+1);
+
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
+ fileSystem.root.getFile(localFileName, {create: true, exclusive: false}, function(fileEntry) {
+ var ft = new FileTransfer();
+ ft.download(remoteFile, fileEntry.fullPath, function(entry) {
+ ok(entry.name == localFileName, "File name returned should match expected");
+ QUnit.start();
+ }, fail);
+ }, fail);
+ }, fail);
+ });
+};