From c452f1a67f41cb1165c92555f0e721fbb07329cc Mon Sep 17 00:00:00 2001 From: alsorokin Date: Fri, 21 Aug 2015 12:18:38 +0300 Subject: [PATCH] CB-9539 Fixed test failure on Android emulator --- tests/plugin.xml | 1 + tests/tests.js | 15 +++++++++------ tests/www/fixtures/asset-test/asset-test.txt | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 tests/www/fixtures/asset-test/asset-test.txt diff --git a/tests/plugin.xml b/tests/plugin.xml index 45d69fc95..1a148fcd2 100644 --- a/tests/plugin.xml +++ b/tests/plugin.xml @@ -38,5 +38,6 @@ android:authorities="org.apache.cordova.file.testprovider" android:exported="false" /> + diff --git a/tests/tests.js b/tests/tests.js index 921ec10ab..2d222d526 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -32,7 +32,6 @@ exports.defineAutoTests = function () { var isWindows = (cordova.platformId === "windows" || cordova.platformId === "windows8"); var MEDIUM_TIMEOUT = 15000; - var LONG_TIMEOUT = 60000; describe('File API', function () { // Adding a Jasmine helper matcher, to report errors when comparing to FileError better. @@ -3484,19 +3483,23 @@ exports.defineAutoTests = function () { }, failed.bind(null, done, 'resolveLocalFileSystemURL failed for content provider')); }); }); + + // these tests ensure that you can read and copy from android_asset folder + // for details see https://issues.apache.org/jira/browse/CB-6428 + // and https://mail-archives.apache.org/mod_mbox/cordova-dev/201508.mbox/%3C782154441.8406572.1440182722528.JavaMail.yahoo%40mail.yahoo.com%3E describe('asset: URLs', function() { it("file.spec.141 filePaths.applicationStorage", function() { expect(cordova.file.applicationDirectory).toEqual('file:///android_asset/'); }, MEDIUM_TIMEOUT); it("file.spec.142 assets should be enumerable", function(done) { - resolveLocalFileSystemURL('file:///android_asset/www/', function(entry) { + resolveLocalFileSystemURL('file:///android_asset/www/fixtures/asset-test', function(entry) { var reader = entry.createReader(); reader.readEntries(function (entries) { expect(entries.length).not.toBe(0); done(); }, failed.bind(null, done, 'reader.readEntries - Error during reading of entries from assets directory')); }, failed.bind(null, done, 'resolveLocalFileSystemURL failed for assets')); - }, LONG_TIMEOUT); + }, MEDIUM_TIMEOUT); it("file.spec.143 copyTo: asset -> temporary", function(done) { var file2 = "entry.copy.file2b", fullPath = joinURL(temp_root.fullPath, file2), @@ -3522,7 +3525,7 @@ exports.defineAutoTests = function () { }, MEDIUM_TIMEOUT); }); it("file.spec.144 copyTo: asset directory", function (done) { - var srcUrl = 'file:///android_asset/www'; + var srcUrl = 'file:///android_asset/www/fixtures/asset-test'; var dstDir = "entry.copy.dstDir"; var dstPath = joinURL(root.fullPath, dstDir); // create a new directory entry to kick off it @@ -3542,7 +3545,7 @@ exports.defineAutoTests = function () { expect(dirEntry.isDirectory).toBe(true); expect(dirEntry.fullPath).toCanonicallyMatch(dstPath); expect(dirEntry.name).toCanonicallyMatch(dstDir); - dirEntry.getFile('cordova.js', { + dirEntry.getFile('asset-test.txt', { create : false }, function (fileEntry) { expect(fileEntry).toBeDefined(); @@ -3554,7 +3557,7 @@ exports.defineAutoTests = function () { }, failed.bind(null, done, 'directory.copyTo - Error copying directory')); }, failed.bind(null, done, 'resolving src dir')); }, failed.bind(null, done, 'deleteEntry - Error removing directory : ' + dstDir)); - }, LONG_TIMEOUT); + }, MEDIUM_TIMEOUT); } }); diff --git a/tests/www/fixtures/asset-test/asset-test.txt b/tests/www/fixtures/asset-test/asset-test.txt new file mode 100644 index 000000000..2ee2df0ef --- /dev/null +++ b/tests/www/fixtures/asset-test/asset-test.txt @@ -0,0 +1 @@ +This file is here for testing purposes \ No newline at end of file