mirror of
https://github.com/apache/cordova-android.git
synced 2026-02-21 00:02:46 +08:00
Compare commits
2 Commits
3.3.0
...
libproject
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d5e2e19e3 | ||
|
|
6859a459a1 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -14,16 +14,11 @@ framework/assets/www/.DS_Store
|
|||||||
framework/assets/www/cordova-*.js
|
framework/assets/www/cordova-*.js
|
||||||
framework/assets/www/phonegap-*.js
|
framework/assets/www/phonegap-*.js
|
||||||
framework/libs
|
framework/libs
|
||||||
framework/javadoc-public
|
|
||||||
framework/javadoc-private
|
|
||||||
test/libs
|
test/libs
|
||||||
example
|
example
|
||||||
./test
|
./test
|
||||||
test/bin
|
test/bin
|
||||||
test/assets/www/.tmp*
|
test/assets/www/.tmp*
|
||||||
test/assets/www/cordova.js
|
|
||||||
test/cordova/plugins/org.apache.cordova.device/www/device.js
|
|
||||||
test/cordova/plugins/org.apache.cordova.device/src/android/Device.java
|
|
||||||
tmp/**
|
tmp/**
|
||||||
.metadata
|
.metadata
|
||||||
tmp/**/*
|
tmp/**/*
|
||||||
|
|||||||
@@ -20,88 +20,6 @@
|
|||||||
-->
|
-->
|
||||||
## Release Notes for Cordova (Android) ##
|
## Release Notes for Cordova (Android) ##
|
||||||
|
|
||||||
### 3.3.0 (Dec 2013) ###
|
|
||||||
|
|
||||||
44 commits by 11 authors, Changes include:
|
|
||||||
|
|
||||||
* Set VERSION to 3.3.0 (via coho)
|
|
||||||
* Update JS snapshot to version 3.3.0 (via coho)
|
|
||||||
* CB-5481 Fix for Cordova trying to get config.xml from the wrong namespace
|
|
||||||
* Forgot Apache Headers on MessageTest
|
|
||||||
* Set VERSION to 3.3.0-rc1 (via coho)
|
|
||||||
* Update JS snapshot to version 3.3.0-rc1 (via coho)
|
|
||||||
* prevent ClassNotFound exception for emtpy class name
|
|
||||||
* CB-5487: Remote Debugging is on when your Android app is debuggable.
|
|
||||||
* Updating the README
|
|
||||||
* Making the object less chatty
|
|
||||||
* Updating tests to KitKat, and making the tests more thread-safe
|
|
||||||
* Incrementing API target
|
|
||||||
* CB-5445: Adding onScrollChanged and the ScrollEvent object. (Forgot to add the WebView)
|
|
||||||
* CB-5445: Adding onScrollChanged and the ScrollEvent object
|
|
||||||
* Updated CordovaWebView to experiment with onScrollChanged messages
|
|
||||||
* Moving the console.log out of run() method
|
|
||||||
* CB-5422: Don't require JAVA_HOME to be defined
|
|
||||||
* Thanks for Benn Mapes for making this process easy. Updating the Android API level.
|
|
||||||
* CB-5490: add javadoc target to ant script
|
|
||||||
* CB-5471: add deprecation javadoc/annotation
|
|
||||||
* Add javadoc comments to source classes
|
|
||||||
* CB-5255: Checking in the Google Check, TODO: Add Amazon FireOS check
|
|
||||||
* CB-5232 Change create script to use Cordova as a library.
|
|
||||||
* Remove Application settings from framework/AndroidManifest.xml
|
|
||||||
* CB-5346: remove dependency on device plugin
|
|
||||||
* CB-5346: delete a stale file that isn't needed
|
|
||||||
* Updating instructions to indicate that the device plugin is required to be installed via plugman
|
|
||||||
* Fixing plugins configuration, Device shouldn't be checked in here
|
|
||||||
* Removing device plugin
|
|
||||||
* Removing the plugins directory after the plugins were incorrectly removed
|
|
||||||
* This should use plugman to install plugins. Adding path depenencies for plugins is wrong, and shouldn't be done
|
|
||||||
* CB-5349: fixed regression in update script
|
|
||||||
* CB-5346 Fix and cleanup broken Android unit test
|
|
||||||
* CB-5307 Remove references to Callback and Incubator
|
|
||||||
* CB-5302: Massive movement to get tests working again
|
|
||||||
* Set VERSION to 3.3.0-dev (via coho)
|
|
||||||
* CB-5301 add missing license headers
|
|
||||||
* [CB-4996] Fix paths with spaces while launching on emulator and device
|
|
||||||
* CB-5284 Fixing the version from coho
|
|
||||||
* Fixing the VERSION file, it got auto-incremented by coho by accident
|
|
||||||
* Update JS snapshot to version 2.10.0-dev (via coho)
|
|
||||||
* Set VERSION to 2.10.0-dev (via coho)
|
|
||||||
* CB-5209 Win: Cannot build Android app if project path contains spaces
|
|
||||||
* CB-5209: Dirty, Dirty Fix for Building. This works, but needs to be prettier.
|
|
||||||
|
|
||||||
### 3.2.0 (Nov 2013) ####
|
|
||||||
|
|
||||||
27 commits by 7 authors, Changes include:
|
|
||||||
|
|
||||||
Set VERSION to 3.2.0 (via coho)
|
|
||||||
* Update JS snapshot to version 3.2.0 (via coho)
|
|
||||||
* CB-5301 add missing license headers
|
|
||||||
* CB-5349: fixed regression in update script
|
|
||||||
* Set VERSION to 3.2.0-rc1 (via coho)
|
|
||||||
* Update JS snapshot to version 3.2.0-rc1 (via coho)
|
|
||||||
* CB-5193 Fix Android WebSQL sometime throwing SECURITY_ERR.
|
|
||||||
* CB-5191 Deprecate <url-filter>
|
|
||||||
* Updating shelljs to 0.2.6. Copy now preserves mode bits.
|
|
||||||
* CB-4872 - moved version script to promise model
|
|
||||||
* CB-4872 - make sure to copy over version scripts to project
|
|
||||||
* [CB-4872] - added android version scripts
|
|
||||||
* CB-5117: Output confirmation message if check_reqs passes.
|
|
||||||
* Refactoring Android project-level and platform scripts to use Q.js
|
|
||||||
* Updating to latest shelljs, old version doesn't preserve +x bits
|
|
||||||
* Remove cordova.xml fallback from Config.java (it was removed from PluginManager for 3.0)
|
|
||||||
* CB-5080 Find resources in a way that works with aapt's --rename-manifest-package
|
|
||||||
* Update JS snapshot to version 3.2.0-dev (via coho)
|
|
||||||
* Remove a couple incorrect lines from RELEASENOTES.md
|
|
||||||
* CB-4961: shell.js returns the full path on ls, rebuilding the full path isn't really needed
|
|
||||||
* Updating README.md to have latest Android SDK
|
|
||||||
* CB-4527: This was an easy fix, since the script deletes batch files
|
|
||||||
* [CB-4892] Fix create script only escaping the first space instead of all spaces.
|
|
||||||
* Fix update script to clobber cordova.js file (missing -f)
|
|
||||||
* Add missing copyright header for Whitelist.java.
|
|
||||||
* [CB-4832] Add 3.1.0 RELEASENOTES.md
|
|
||||||
* Update JS snapshot to version 3.2.0-dev (via coho)
|
|
||||||
* Set VERSION to 3.2.0-dev (via coho)
|
|
||||||
|
|
||||||
### 3.1.0 (Sept 2013) ###
|
### 3.1.0 (Sept 2013) ###
|
||||||
|
|
||||||
55 commits from 9 authors. Highlights include:
|
55 commits from 9 authors. Highlights include:
|
||||||
|
|||||||
@@ -21,11 +21,8 @@
|
|||||||
|
|
||||||
var check_reqs = require('./lib/check_reqs');
|
var check_reqs = require('./lib/check_reqs');
|
||||||
|
|
||||||
check_reqs.run().done(
|
check_reqs.run().done(null, function(err) {
|
||||||
function success() {
|
console.log(err);
|
||||||
console.log('Looks like your environment fully supports cordova-android development!');
|
process.exit(2);
|
||||||
}, function fail(err) {
|
});
|
||||||
console.log(err);
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -33,10 +33,8 @@ module.exports.get_target = function() {
|
|||||||
return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
|
return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
|
||||||
} else if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
|
} else if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
|
||||||
// if no target found, we're probably in a project and project.properties is in ROOT.
|
// if no target found, we're probably in a project and project.properties is in ROOT.
|
||||||
// this is called on the project itself, and can support Google APIs AND Vanilla Android
|
var target = shell.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties'));
|
||||||
var target = shell.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties')) ||
|
return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
|
||||||
shell.grep(/target=Google Inc.:Google APIs:[\d+]/, path.join(ROOT, 'project.properties'));
|
|
||||||
return target.split('=')[1].replace('\n', '').replace('\r', '');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,18 +50,16 @@ module.exports.check_ant = function() {
|
|||||||
|
|
||||||
// Returns a promise.
|
// Returns a promise.
|
||||||
module.exports.check_java = function() {
|
module.exports.check_java = function() {
|
||||||
var d = Q.defer();
|
if(process.env.JAVA_HOME) {
|
||||||
child_process.exec('java -version', function(err, stdout, stderr) {
|
var d = Q.defer();
|
||||||
if(err) {
|
child_process.exec('java -version', function(err, stdout, stderr) {
|
||||||
var msg =
|
if(err) d.reject(new Error('ERROR : executing command \'java\', make sure you java environment is set up. Including your JDK and JRE.' + err));
|
||||||
'Failed to run \'java -version\', make sure your java environment is set up\n' +
|
else d.resolve();
|
||||||
'including JDK and JRE.\n' +
|
});
|
||||||
'Your JAVA_HOME variable is ' + process.env.JAVA_HOME + '\n';
|
return d.promise;
|
||||||
d.reject(new Error(msg + err));
|
} else {
|
||||||
}
|
return Q.reject(new Error('ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.'));
|
||||||
else d.resolve();
|
}
|
||||||
});
|
|
||||||
return d.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a promise.
|
// Returns a promise.
|
||||||
@@ -91,6 +87,8 @@ module.exports.check_android = function() {
|
|||||||
|
|
||||||
// Returns a promise.
|
// Returns a promise.
|
||||||
module.exports.run = function() {
|
module.exports.run = function() {
|
||||||
return Q.all([this.check_ant(), this.check_java(), this.check_android()]);
|
return Q.all([this.check_ant(), this.check_java(), this.check_android()]).then(function() {
|
||||||
|
console.log('Looks like your environment fully supports cordova-android development!');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -189,10 +189,10 @@ exports.createProject = function(project_path, package_name, project_name, proje
|
|||||||
|
|
||||||
// Returns a promise.
|
// Returns a promise.
|
||||||
exports.updateProject = function(projectPath) {
|
exports.updateProject = function(projectPath) {
|
||||||
var version = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
|
|
||||||
// Check that requirements are met and proper targets are installed
|
// Check that requirements are met and proper targets are installed
|
||||||
return check_reqs.run()
|
return check_reqs.run()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
var version = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
|
||||||
var target_api = check_reqs.get_target();
|
var target_api = check_reqs.get_target();
|
||||||
copyJsAndLibrary(projectPath, false, null);
|
copyJsAndLibrary(projectPath, false, null);
|
||||||
copyScripts(projectPath);
|
copyScripts(projectPath);
|
||||||
|
|||||||
2
bin/templates/cordova/lib/device.js
vendored
2
bin/templates/cordova/lib/device.js
vendored
@@ -64,7 +64,7 @@ module.exports.install = function(target) {
|
|||||||
var apk_path = build.get_apk();
|
var apk_path = build.get_apk();
|
||||||
launchName = appinfo.getActivityName();
|
launchName = appinfo.getActivityName();
|
||||||
console.log('Installing app on device...');
|
console.log('Installing app on device...');
|
||||||
var cmd = 'adb -s ' + target + ' install -r "' + apk_path + '"';
|
var cmd = 'adb -s ' + target + ' install -r ' + apk_path;
|
||||||
return exec(cmd);
|
return exec(cmd);
|
||||||
}).then(function(output) {
|
}).then(function(output) {
|
||||||
if (output.match(/Failure/)) return Q.reject('ERROR: Failed to install apk to device: ' + output);
|
if (output.match(/Failure/)) return Q.reject('ERROR: Failed to install apk to device: ' + output);
|
||||||
|
|||||||
2
bin/templates/cordova/lib/emulator.js
vendored
2
bin/templates/cordova/lib/emulator.js
vendored
@@ -305,7 +305,7 @@ module.exports.install = function(target) {
|
|||||||
|
|
||||||
console.log('Installing app on emulator...');
|
console.log('Installing app on emulator...');
|
||||||
var apk_path = build.get_apk();
|
var apk_path = build.get_apk();
|
||||||
return exec('adb -s ' + target + ' install -r "' + apk_path + '"');
|
return exec('adb -s ' + target + ' install -r ' + apk_path);
|
||||||
}).then(function(output) {
|
}).then(function(output) {
|
||||||
if (output.match(/Failure/)) {
|
if (output.match(/Failure/)) {
|
||||||
return Q.reject('Failed to install apk to emulator: ' + output);
|
return Q.reject('Failed to install apk to emulator: ' + output);
|
||||||
|
|||||||
@@ -20,6 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Coho updates this line:
|
// Coho updates this line:
|
||||||
var VERSION = "3.3.0";
|
var VERSION = "3.2.0-dev";
|
||||||
|
|
||||||
console.log(VERSION);
|
console.log(VERSION);
|
||||||
|
|||||||
40
framework/assets/www/cordova.js
vendored
40
framework/assets/www/cordova.js
vendored
@@ -1,5 +1,5 @@
|
|||||||
// Platform: android
|
// Platform: android
|
||||||
// 3.3.0
|
// 3.2.0-dev-5ad41a7
|
||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
;(function() {
|
;(function() {
|
||||||
var CORDOVA_JS_BUILD_LABEL = '3.3.0';
|
var CORDOVA_JS_BUILD_LABEL = '3.2.0-dev-5ad41a7';
|
||||||
// file: lib/scripts/require.js
|
// file: lib/scripts/require.js
|
||||||
|
|
||||||
/*jshint -W079 */
|
/*jshint -W079 */
|
||||||
@@ -34,7 +34,7 @@ var require,
|
|||||||
requireStack = [],
|
requireStack = [],
|
||||||
// Map of module ID -> index into requireStack of modules currently being built.
|
// Map of module ID -> index into requireStack of modules currently being built.
|
||||||
inProgressModules = {},
|
inProgressModules = {},
|
||||||
SEPARATOR = ".";
|
SEPERATOR = ".";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ var require,
|
|||||||
var resultantId = id;
|
var resultantId = id;
|
||||||
//Its a relative path, so lop off the last portion and add the id (minus "./")
|
//Its a relative path, so lop off the last portion and add the id (minus "./")
|
||||||
if (id.charAt(0) === ".") {
|
if (id.charAt(0) === ".") {
|
||||||
resultantId = module.id.slice(0, module.id.lastIndexOf(SEPARATOR)) + SEPARATOR + id.slice(2);
|
resultantId = module.id.slice(0, module.id.lastIndexOf(SEPERATOR)) + SEPERATOR + id.slice(2);
|
||||||
}
|
}
|
||||||
return require(resultantId);
|
return require(resultantId);
|
||||||
};
|
};
|
||||||
@@ -552,7 +552,7 @@ function include(parent, objects, clobber, merge) {
|
|||||||
include(result, obj.children, clobber, merge);
|
include(result, obj.children, clobber, merge);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
utils.alert('Exception building Cordova JS globals: ' + e + ' for key "' + key + '"');
|
utils.alert('Exception building cordova JS globals: ' + e + ' for key "' + key + '"');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1074,36 +1074,6 @@ module.exports = androidExec;
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// file: lib/common/exec/proxy.js
|
|
||||||
define("cordova/exec/proxy", function(require, exports, module) {
|
|
||||||
|
|
||||||
|
|
||||||
// internal map of proxy function
|
|
||||||
var CommandProxyMap = {};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
|
|
||||||
// example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
|
|
||||||
add:function(id,proxyObj) {
|
|
||||||
console.log("adding proxy for " + id);
|
|
||||||
CommandProxyMap[id] = proxyObj;
|
|
||||||
return proxyObj;
|
|
||||||
},
|
|
||||||
|
|
||||||
// cordova.commandProxy.remove("Accelerometer");
|
|
||||||
remove:function(id) {
|
|
||||||
var proxy = CommandProxyMap[id];
|
|
||||||
delete CommandProxyMap[id];
|
|
||||||
CommandProxyMap[id] = null;
|
|
||||||
return proxy;
|
|
||||||
},
|
|
||||||
|
|
||||||
get:function(service,action) {
|
|
||||||
return ( CommandProxyMap[service] ? CommandProxyMap[service][action] : null );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// file: lib/common/init.js
|
// file: lib/common/init.js
|
||||||
define("cordova/init", function(require, exports, module) {
|
define("cordova/init", function(require, exports, module) {
|
||||||
|
|
||||||
|
|||||||
@@ -95,13 +95,6 @@
|
|||||||
<target name="-post-compile">
|
<target name="-post-compile">
|
||||||
</target>
|
</target>
|
||||||
-->
|
-->
|
||||||
<target name="-pre-clean">
|
|
||||||
<!-- delete generated javadoc -->
|
|
||||||
<delete dir="javadoc-public" failonerror="false" />
|
|
||||||
<delete dir="javadoc-private" failonerror="false" />
|
|
||||||
<!-- delete generated jar -->
|
|
||||||
<delete file="cordova-${version}.jar" failonerror="false" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- Import the actual build file.
|
<!-- Import the actual build file.
|
||||||
|
|
||||||
@@ -127,31 +120,7 @@
|
|||||||
that includes all JavaScript code.
|
that includes all JavaScript code.
|
||||||
-->
|
-->
|
||||||
<target name="jar" depends="-compile">
|
<target name="jar" depends="-compile">
|
||||||
<jar
|
<jar jarfile="cordova-${version}.jar" basedir="bin/classes" excludes="org/apache/cordova/R.class,org/apache/cordova/R$*.class"/>
|
||||||
basedir="bin/classes"
|
|
||||||
excludes="org/apache/cordova/R.class,org/apache/cordova/R$*.class"
|
|
||||||
jarfile="cordova-${version}.jar" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="javadoc">
|
|
||||||
<delete dir="javadoc-public" failonerror="false" />
|
|
||||||
<javadoc
|
|
||||||
access="public"
|
|
||||||
destdir="javadoc-public"
|
|
||||||
classpath="${sdk.dir}/platforms/${target}/android.jar">
|
|
||||||
<packageset dir="src">
|
|
||||||
<include name="org/apache/cordova/**" />
|
|
||||||
</packageset>
|
|
||||||
</javadoc>
|
|
||||||
<delete dir="javadoc-private" failonerror="false" />
|
|
||||||
<javadoc
|
|
||||||
access="private"
|
|
||||||
destdir="javadoc-private"
|
|
||||||
classpath="${sdk.dir}/platforms/${target}/android.jar">
|
|
||||||
<packageset dir="src">
|
|
||||||
<include name="org/apache/cordova/**" />
|
|
||||||
</packageset>
|
|
||||||
</javadoc>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- tests for Java files -->
|
<!-- tests for Java files -->
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
# Indicates whether an apk should be generated for each density.
|
# Indicates whether an apk should be generated for each density.
|
||||||
split.density=false
|
split.density=false
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-19
|
target=android-18
|
||||||
apk-configurations=
|
apk-configurations=
|
||||||
renderscript.opt.level=O0
|
renderscript.opt.level=O0
|
||||||
android.library=true
|
android.library=true
|
||||||
|
|||||||
@@ -68,15 +68,10 @@ public class Config {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First checking the class namespace for config.xml
|
|
||||||
int id = action.getResources().getIdentifier("config", "xml", action.getClass().getPackage().getName());
|
int id = action.getResources().getIdentifier("config", "xml", action.getClass().getPackage().getName());
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
// If we couldn't find config.xml there, we'll look in the namespace from AndroidManifest.xml
|
LOG.i("CordovaLog", "config.xml missing. Ignoring...");
|
||||||
id = action.getResources().getIdentifier("config", "xml", action.getPackageName());
|
return;
|
||||||
if (id == 0) {
|
|
||||||
LOG.i("CordovaLog", "config.xml missing. Ignoring...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add implicitly allowed URLs
|
// Add implicitly allowed URLs
|
||||||
@@ -213,7 +208,7 @@ public class Config {
|
|||||||
* Determine if URL is in approved list of URLs to load.
|
* Determine if URL is in approved list of URLs to load.
|
||||||
*
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* @return true if whitelisted
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isUrlWhiteListed(String url) {
|
public static boolean isUrlWhiteListed(String url) {
|
||||||
if (self == null) {
|
if (self == null) {
|
||||||
|
|||||||
@@ -63,14 +63,13 @@ import android.widget.LinearLayout;
|
|||||||
* html file that contains the application.
|
* html file that contains the application.
|
||||||
*
|
*
|
||||||
* As an example:
|
* As an example:
|
||||||
*
|
*
|
||||||
* <pre>
|
|
||||||
* package org.apache.cordova.examples;
|
* package org.apache.cordova.examples;
|
||||||
* import android.os.Bundle;
|
* import android.os.Bundle;
|
||||||
* import org.apache.cordova.*;
|
* import org.apache.cordova.*;
|
||||||
*
|
*
|
||||||
* public class Example extends CordovaActivity {
|
* public class Example extends CordovaActivity {
|
||||||
* @Override
|
* @Override
|
||||||
* public void onCreate(Bundle savedInstanceState) {
|
* public void onCreate(Bundle savedInstanceState) {
|
||||||
* super.onCreate(savedInstanceState);
|
* super.onCreate(savedInstanceState);
|
||||||
*
|
*
|
||||||
@@ -86,11 +85,9 @@ import android.widget.LinearLayout;
|
|||||||
* super.loadUrl("file:///android_asset/www/index.html", 3000); // show splash screen 3 sec before loading app
|
* super.loadUrl("file:///android_asset/www/index.html", 3000); // show splash screen 3 sec before loading app
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
*
|
||||||
*
|
|
||||||
* Properties: The application can be configured using the following properties:
|
* Properties: The application can be configured using the following properties:
|
||||||
*
|
*
|
||||||
* <pre>
|
|
||||||
* // Display a native loading dialog when loading app. Format for value = "Title,Message".
|
* // Display a native loading dialog when loading app. Format for value = "Title,Message".
|
||||||
* // (String - default=null)
|
* // (String - default=null)
|
||||||
* super.setStringProperty("loadingDialog", "Wait,Loading Demo...");
|
* super.setStringProperty("loadingDialog", "Wait,Loading Demo...");
|
||||||
@@ -117,19 +114,15 @@ import android.widget.LinearLayout;
|
|||||||
*
|
*
|
||||||
* // Enable app to keep running in background. (Boolean - default=true)
|
* // Enable app to keep running in background. (Boolean - default=true)
|
||||||
* super.setBooleanProperty("keepRunning", false);
|
* super.setBooleanProperty("keepRunning", false);
|
||||||
* </pre>
|
|
||||||
*
|
*
|
||||||
* Cordova.xml configuration:
|
* Cordova.xml configuration:
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* Cordova uses a configuration file at res/xml/cordova.xml to specify the following settings.
|
* Cordova uses a configuration file at res/xml/cordova.xml to specify the following settings.
|
||||||
*
|
*
|
||||||
* Approved list of URLs that can be loaded into Cordova
|
* Approved list of URLs that can be loaded into Cordova
|
||||||
* <access origin="http://server regexp" subdomains="true" />
|
* <access origin="http://server regexp" subdomains="true" />
|
||||||
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
|
* Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
|
||||||
* <log level="DEBUG" />
|
* <log level="DEBUG" />
|
||||||
* </pre>
|
*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CordovaActivity extends Activity implements CordovaInterface {
|
public class CordovaActivity extends Activity implements CordovaInterface {
|
||||||
public static String TAG = "CordovaActivity";
|
public static String TAG = "CordovaActivity";
|
||||||
@@ -298,7 +291,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
/**
|
/**
|
||||||
* Get the Android activity.
|
* Get the Android activity.
|
||||||
*
|
*
|
||||||
* @return the Activity
|
* @return
|
||||||
*/
|
*/
|
||||||
public Activity getActivity() {
|
public Activity getActivity() {
|
||||||
return this;
|
return this;
|
||||||
@@ -551,7 +544,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param defaultValue
|
* @param defaultValue
|
||||||
* @return the boolean value of the named property
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean getBooleanProperty(String name, boolean defaultValue) {
|
public boolean getBooleanProperty(String name, boolean defaultValue) {
|
||||||
Bundle bundle = this.getIntent().getExtras();
|
Bundle bundle = this.getIntent().getExtras();
|
||||||
@@ -582,7 +575,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param defaultValue
|
* @param defaultValue
|
||||||
* @return the int value for the named property
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getIntegerProperty(String name, int defaultValue) {
|
public int getIntegerProperty(String name, int defaultValue) {
|
||||||
Bundle bundle = this.getIntent().getExtras();
|
Bundle bundle = this.getIntent().getExtras();
|
||||||
@@ -607,7 +600,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param defaultValue
|
* @param defaultValue
|
||||||
* @return the String value for the named property
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getStringProperty(String name, String defaultValue) {
|
public String getStringProperty(String name, String defaultValue) {
|
||||||
Bundle bundle = this.getIntent().getExtras();
|
Bundle bundle = this.getIntent().getExtras();
|
||||||
@@ -627,7 +620,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param defaultValue
|
* @param defaultValue
|
||||||
* @return the double value for the named property
|
* @return
|
||||||
*/
|
*/
|
||||||
public double getDoubleProperty(String name, double defaultValue) {
|
public double getDoubleProperty(String name, double defaultValue) {
|
||||||
Bundle bundle = this.getIntent().getExtras();
|
Bundle bundle = this.getIntent().getExtras();
|
||||||
@@ -649,14 +642,10 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set boolean property on activity.
|
* Set boolean property on activity.
|
||||||
* This method has been deprecated in 3.0 and will be removed at a future
|
|
||||||
* time. Please use config.xml instead.
|
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public void setBooleanProperty(String name, boolean value) {
|
public void setBooleanProperty(String name, boolean value) {
|
||||||
Log.d(TAG, "Setting boolean properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
|
Log.d(TAG, "Setting boolean properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
|
||||||
this.getIntent().putExtra(name.toLowerCase(), value);
|
this.getIntent().putExtra(name.toLowerCase(), value);
|
||||||
@@ -664,14 +653,10 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set int property on activity.
|
* Set int property on activity.
|
||||||
* This method has been deprecated in 3.0 and will be removed at a future
|
|
||||||
* time. Please use config.xml instead.
|
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public void setIntegerProperty(String name, int value) {
|
public void setIntegerProperty(String name, int value) {
|
||||||
Log.d(TAG, "Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
|
Log.d(TAG, "Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
|
||||||
this.getIntent().putExtra(name.toLowerCase(), value);
|
this.getIntent().putExtra(name.toLowerCase(), value);
|
||||||
@@ -679,14 +664,10 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set string property on activity.
|
* Set string property on activity.
|
||||||
* This method has been deprecated in 3.0 and will be removed at a future
|
|
||||||
* time. Please use config.xml instead.
|
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public void setStringProperty(String name, String value) {
|
public void setStringProperty(String name, String value) {
|
||||||
Log.d(TAG, "Setting string properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
|
Log.d(TAG, "Setting string properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
|
||||||
this.getIntent().putExtra(name.toLowerCase(), value);
|
this.getIntent().putExtra(name.toLowerCase(), value);
|
||||||
@@ -694,14 +675,10 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set double property on activity.
|
* Set double property on activity.
|
||||||
* This method has been deprecated in 3.0 and will be removed at a future
|
|
||||||
* time. Please use config.xml instead.
|
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param value
|
* @param value
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public void setDoubleProperty(String name, double value) {
|
public void setDoubleProperty(String name, double value) {
|
||||||
Log.d(TAG, "Setting double properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
|
Log.d(TAG, "Setting double properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml");
|
||||||
this.getIntent().putExtra(name.toLowerCase(), value);
|
this.getIntent().putExtra(name.toLowerCase(), value);
|
||||||
@@ -822,7 +799,6 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
* @param serviceType
|
* @param serviceType
|
||||||
* @param className
|
* @param className
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public void addService(String serviceType, String className) {
|
public void addService(String serviceType, String className) {
|
||||||
if (this.appView != null && this.appView.pluginManager != null) {
|
if (this.appView != null && this.appView.pluginManager != null) {
|
||||||
this.appView.pluginManager.addService(serviceType, className);
|
this.appView.pluginManager.addService(serviceType, className);
|
||||||
@@ -1021,7 +997,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
* Determine if URL is in approved list of URLs to load.
|
* Determine if URL is in approved list of URLs to load.
|
||||||
*
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* @return true if the url is whitelisted
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isUrlWhiteListed(String url) {
|
public boolean isUrlWhiteListed(String url) {
|
||||||
return Config.isUrlWhiteListed(url);
|
return Config.isUrlWhiteListed(url);
|
||||||
@@ -1052,10 +1028,8 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
/**
|
/**
|
||||||
* Get Activity context.
|
* Get Activity context.
|
||||||
*
|
*
|
||||||
* @return self
|
* @return
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public Context getContext() {
|
public Context getContext() {
|
||||||
LOG.d(TAG, "This will be deprecated December 2012");
|
LOG.d(TAG, "This will be deprecated December 2012");
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -47,14 +47,6 @@ import android.widget.RelativeLayout;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the WebChromeClient that implements callbacks for our web view.
|
* This class is the WebChromeClient that implements callbacks for our web view.
|
||||||
* The kind of callbacks that happen here are on the chrome outside the document,
|
|
||||||
* such as onCreateWindow(), onConsoleMessage(), onProgressChanged(), etc. Related
|
|
||||||
* to but different than CordovaWebViewClient.
|
|
||||||
*
|
|
||||||
* @see <a href="http://developer.android.com/reference/android/webkit/WebChromeClient.html">WebChromeClient</a>
|
|
||||||
* @see <a href="http://developer.android.com/guide/webapps/webview.html">WebView guide</a>
|
|
||||||
* @see CordovaWebViewClient
|
|
||||||
* @see CordovaWebView
|
|
||||||
*/
|
*/
|
||||||
public class CordovaChromeClient extends WebChromeClient {
|
public class CordovaChromeClient extends WebChromeClient {
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public interface CordovaInterface {
|
|||||||
/**
|
/**
|
||||||
* Get the Android activity.
|
* Get the Android activity.
|
||||||
*
|
*
|
||||||
* @return the Activity
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract Activity getActivity();
|
public abstract Activity getActivity();
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -59,16 +56,12 @@ import android.webkit.WebView;
|
|||||||
import android.webkit.WebSettings.LayoutAlgorithm;
|
import android.webkit.WebSettings.LayoutAlgorithm;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
/*
|
|
||||||
* This class is our web view.
|
|
||||||
*
|
|
||||||
* @see <a href="http://developer.android.com/guide/webapps/webview.html">WebView guide</a>
|
|
||||||
* @see <a href="http://developer.android.com/reference/android/webkit/WebView.html">WebView</a>
|
|
||||||
*/
|
|
||||||
public class CordovaWebView extends WebView {
|
public class CordovaWebView extends WebView {
|
||||||
|
|
||||||
|
|
||||||
public static final String TAG = "CordovaWebView";
|
public static final String TAG = "CordovaWebView";
|
||||||
public static final String CORDOVA_VERSION = "3.3.0";
|
|
||||||
|
public static final String CORDOVA_VERSION = "3.2.0-dev";
|
||||||
|
|
||||||
private ArrayList<Integer> keyDownCodes = new ArrayList<Integer>();
|
private ArrayList<Integer> keyDownCodes = new ArrayList<Integer>();
|
||||||
private ArrayList<Integer> keyUpCodes = new ArrayList<Integer>();
|
private ArrayList<Integer> keyUpCodes = new ArrayList<Integer>();
|
||||||
@@ -217,9 +210,7 @@ public class CordovaWebView extends WebView {
|
|||||||
this.setup();
|
this.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* set the WebViewClient, but provide special case handling for IceCreamSandwich.
|
|
||||||
*/
|
|
||||||
private void initWebViewClient(CordovaInterface cordova) {
|
private void initWebViewClient(CordovaInterface cordova) {
|
||||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB ||
|
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB ||
|
||||||
android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.JELLY_BEAN_MR1)
|
android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||||
@@ -284,28 +275,6 @@ public class CordovaWebView extends WebView {
|
|||||||
settings.setDatabaseEnabled(true);
|
settings.setDatabaseEnabled(true);
|
||||||
settings.setDatabasePath(databasePath);
|
settings.setDatabasePath(databasePath);
|
||||||
|
|
||||||
|
|
||||||
//Determine whether we're in debug or release mode, and turn on Debugging!
|
|
||||||
try {
|
|
||||||
final String packageName = this.cordova.getActivity().getPackageName();
|
|
||||||
final PackageManager pm = this.cordova.getActivity().getPackageManager();
|
|
||||||
ApplicationInfo appInfo;
|
|
||||||
|
|
||||||
appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
|
|
||||||
|
|
||||||
if((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 &&
|
|
||||||
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
|
|
||||||
{
|
|
||||||
setWebContentsDebuggingEnabled(true);
|
|
||||||
}
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Log.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! ");
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
Log.d(TAG, "This should never happen: Your application's package can't be found.");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.setGeolocationDatabasePath(databasePath);
|
settings.setGeolocationDatabasePath(databasePath);
|
||||||
|
|
||||||
// Enable DOM storage
|
// Enable DOM storage
|
||||||
@@ -346,10 +315,10 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this method to decide whether or not you need to request the
|
* Override this method to decide wether or not you need to request the
|
||||||
* focus when your application start
|
* focus when your application start
|
||||||
*
|
*
|
||||||
* @return true unless this method is overriden to return a different value
|
* @return
|
||||||
*/
|
*/
|
||||||
protected boolean shouldRequestFocusOnInit() {
|
protected boolean shouldRequestFocusOnInit() {
|
||||||
return true;
|
return true;
|
||||||
@@ -542,15 +511,6 @@ public class CordovaWebView extends WebView {
|
|||||||
this.loadUrlIntoView(url);
|
this.loadUrlIntoView(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onScrollChanged(int l, int t, int oldl, int oldt)
|
|
||||||
{
|
|
||||||
super.onScrollChanged(l, t, oldl, oldt);
|
|
||||||
//We should post a message that the scroll changed
|
|
||||||
ScrollEvent myEvent = new ScrollEvent(l, t, oldl, oldt, this);
|
|
||||||
this.postMessage("onScrollChanged", myEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send JavaScript statement back to JavaScript.
|
* Send JavaScript statement back to JavaScript.
|
||||||
* (This is a convenience method)
|
* (This is a convenience method)
|
||||||
@@ -676,7 +636,7 @@ public class CordovaWebView extends WebView {
|
|||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param defaultValue
|
* @param defaultValue
|
||||||
* @return the String value for the named property
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getProperty(String name, String defaultValue) {
|
public String getProperty(String name, String defaultValue) {
|
||||||
Bundle bundle = this.cordova.getActivity().getIntent().getExtras();
|
Bundle bundle = this.cordova.getActivity().getIntent().getExtras();
|
||||||
@@ -916,7 +876,7 @@ public class CordovaWebView extends WebView {
|
|||||||
{
|
{
|
||||||
WebHistoryItem item = currentList.getItemAtIndex(i);
|
WebHistoryItem item = currentList.getItemAtIndex(i);
|
||||||
String url = item.getUrl();
|
String url = item.getUrl();
|
||||||
LOG.d(TAG, "The URL at index: " + Integer.toString(i) + " is " + url );
|
LOG.d(TAG, "The URL at index: " + Integer.toString(i) + "is " + url );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -930,7 +890,7 @@ public class CordovaWebView extends WebView {
|
|||||||
String url = item.getUrl();
|
String url = item.getUrl();
|
||||||
String currentUrl = this.getUrl();
|
String currentUrl = this.getUrl();
|
||||||
LOG.d(TAG, "The current URL is: " + currentUrl);
|
LOG.d(TAG, "The current URL is: " + currentUrl);
|
||||||
LOG.d(TAG, "The URL at item 0 is: " + url);
|
LOG.d(TAG, "The URL at item 0 is:" + url);
|
||||||
return currentUrl.equals(url);
|
return currentUrl.equals(url);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -983,7 +943,7 @@ public class CordovaWebView extends WebView {
|
|||||||
* if the video overlay is showing then we need to know
|
* if the video overlay is showing then we need to know
|
||||||
* as it effects back button handling
|
* as it effects back button handling
|
||||||
*
|
*
|
||||||
* @return true if custom view is showing
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isCustomViewShowing() {
|
public boolean isCustomViewShowing() {
|
||||||
return mCustomView != null;
|
return mCustomView != null;
|
||||||
|
|||||||
@@ -45,15 +45,6 @@ import android.webkit.WebViewClient;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the WebViewClient that implements callbacks for our web view.
|
* This class is the WebViewClient that implements callbacks for our web view.
|
||||||
* The kind of callbacks that happen here are regarding the rendering of the
|
|
||||||
* document instead of the chrome surrounding it, such as onPageStarted(),
|
|
||||||
* shouldOverrideUrlLoading(), etc. Related to but different than
|
|
||||||
* CordovaChromeClient.
|
|
||||||
*
|
|
||||||
* @see <a href="http://developer.android.com/reference/android/webkit/WebViewClient.html">WebViewClient</a>
|
|
||||||
* @see <a href="http://developer.android.com/guide/webapps/webview.html">WebView guide</a>
|
|
||||||
* @see CordovaChromeClient
|
|
||||||
* @see CordovaWebView
|
|
||||||
*/
|
*/
|
||||||
public class CordovaWebViewClient extends WebViewClient {
|
public class CordovaWebViewClient extends WebViewClient {
|
||||||
|
|
||||||
|
|||||||
@@ -17,18 +17,10 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// We moved everything to CordovaActivity
|
||||||
|
|
||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
/**
|
|
||||||
* This used to be the class that should be extended by application
|
|
||||||
* developers, but everything has been moved to CordovaActivity. So
|
|
||||||
* you should extend CordovaActivity instead of DroidGap. This class
|
|
||||||
* will be removed at a future time.
|
|
||||||
*
|
|
||||||
* @see CordovaActivity
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class DroidGap extends CordovaActivity {
|
public class DroidGap extends CordovaActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class LOG {
|
|||||||
* Determine if log level will be logged
|
* Determine if log level will be logged
|
||||||
*
|
*
|
||||||
* @param logLevel
|
* @param logLevel
|
||||||
* @return true if the parameter passed in is greater than or equal to the current log level
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isLoggable(int logLevel) {
|
public static boolean isLoggable(int logLevel) {
|
||||||
return (logLevel >= LOGLEVEL);
|
return (logLevel >= LOGLEVEL);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import android.webkit.WebView;
|
|||||||
public class NativeToJsMessageQueue {
|
public class NativeToJsMessageQueue {
|
||||||
private static final String LOG_TAG = "JsMessageQueue";
|
private static final String LOG_TAG = "JsMessageQueue";
|
||||||
|
|
||||||
// This must match the default value in cordova-js/lib/android/exec.js
|
// This must match the default value in incubator-cordova-js/lib/android/exec.js
|
||||||
private static final int DEFAULT_BRIDGE_MODE = 2;
|
private static final int DEFAULT_BRIDGE_MODE = 2;
|
||||||
|
|
||||||
// Set this to true to force plugin results to be encoding as
|
// Set this to true to force plugin results to be encoding as
|
||||||
|
|||||||
@@ -107,13 +107,13 @@ public class PluginEntry {
|
|||||||
* Get the class.
|
* Get the class.
|
||||||
*
|
*
|
||||||
* @param clazz
|
* @param clazz
|
||||||
* @return a reference to the named class
|
* @return
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private Class getClassByName(final String clazz) throws ClassNotFoundException {
|
private Class getClassByName(final String clazz) throws ClassNotFoundException {
|
||||||
Class c = null;
|
Class c = null;
|
||||||
if ((clazz != null) && !("".equals(clazz))) {
|
if (clazz != null) {
|
||||||
c = Class.forName(clazz);
|
c = Class.forName(clazz);
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
|
|||||||
@@ -110,16 +110,11 @@ public class PluginManager {
|
|||||||
* Load plugins from res/xml/config.xml
|
* Load plugins from res/xml/config.xml
|
||||||
*/
|
*/
|
||||||
public void loadPlugins() {
|
public void loadPlugins() {
|
||||||
// First checking the class namespace for config.xml
|
|
||||||
int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getClass().getPackage().getName());
|
int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getClass().getPackage().getName());
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
// If we couldn't find config.xml there, we'll look in the namespace from AndroidManifest.xml
|
this.pluginConfigurationMissing();
|
||||||
id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName());
|
//We have the error, we need to exit without crashing!
|
||||||
if (id == 0) {
|
return;
|
||||||
this.pluginConfigurationMissing();
|
|
||||||
//We have the error, we need to exit without crashing!
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
|
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
|
||||||
int eventType = -1;
|
int eventType = -1;
|
||||||
@@ -344,7 +339,7 @@ public class PluginManager {
|
|||||||
*
|
*
|
||||||
* @param id The message id
|
* @param id The message id
|
||||||
* @param data The message data
|
* @param data The message data
|
||||||
* @return Object to stop propagation or null
|
* @return
|
||||||
*/
|
*/
|
||||||
public Object postMessage(String id, Object data) {
|
public Object postMessage(String id, Object data) {
|
||||||
Object obj = this.ctx.onMessage(id, data);
|
Object obj = this.ctx.onMessage(id, data);
|
||||||
@@ -418,7 +413,7 @@ public class PluginManager {
|
|||||||
private void pluginConfigurationMissing() {
|
private void pluginConfigurationMissing() {
|
||||||
LOG.e(TAG, "=====================================================================================");
|
LOG.e(TAG, "=====================================================================================");
|
||||||
LOG.e(TAG, "ERROR: config.xml is missing. Add res/xml/config.xml to your project.");
|
LOG.e(TAG, "ERROR: config.xml is missing. Add res/xml/config.xml to your project.");
|
||||||
LOG.e(TAG, "https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=blob;f=framework/res/xml/config.xml");
|
LOG.e(TAG, "https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml");
|
||||||
LOG.e(TAG, "=====================================================================================");
|
LOG.e(TAG, "=====================================================================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.cordova;
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This can be used by any view, including native views
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
public class ScrollEvent {
|
|
||||||
|
|
||||||
public int l, t, nl, nt;
|
|
||||||
private View targetView;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ScrollEvent constructor
|
|
||||||
* No idea why it uses l and t instead of x and y
|
|
||||||
*
|
|
||||||
* @param x
|
|
||||||
* @param y
|
|
||||||
* @param nx
|
|
||||||
* @param ny
|
|
||||||
* @param view
|
|
||||||
*/
|
|
||||||
|
|
||||||
ScrollEvent(int nx, int ny, int x, int y, View view)
|
|
||||||
{
|
|
||||||
l = x; y = t; nl = nx; nt = ny;
|
|
||||||
targetView = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int dl()
|
|
||||||
{
|
|
||||||
return nl - l;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int dt()
|
|
||||||
{
|
|
||||||
return nt - t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public View getTargetView()
|
|
||||||
{
|
|
||||||
return targetView;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -149,7 +149,7 @@ public class Whitelist {
|
|||||||
* Determine if URL is in approved list of URLs to load.
|
* Determine if URL is in approved list of URLs to load.
|
||||||
*
|
*
|
||||||
* @param uri
|
* @param uri
|
||||||
* @return true if wide open or whitelisted
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isUrlWhiteListed(String uri) {
|
public boolean isUrlWhiteListed(String uri) {
|
||||||
// If there is no whitelist, then it's wide open
|
// If there is no whitelist, then it's wide open
|
||||||
|
|||||||
@@ -4,6 +4,5 @@
|
|||||||
<classpathentry kind="src" path="gen"/>
|
<classpathentry kind="src" path="gen"/>
|
||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
|
||||||
<classpathentry kind="output" path="bin/classes"/>
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
|
<uses-sdk android:minSdkVersion="8" />
|
||||||
|
|
||||||
<instrumentation
|
<instrumentation
|
||||||
android:name="android.test.InstrumentationTestRunner"
|
android:name="android.test.InstrumentationTestRunner"
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.CordovaWebViewTestActivity" >
|
android:name=".actions.CordovaWebViewTestActivity" >
|
||||||
<intent-filter >
|
<intent-filter >
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.background" >
|
android:name=".actions.background" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.backgroundcolor" >
|
android:name=".actions.backgroundcolor" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.basicauth" >
|
android:name=".actions.basicauth" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.CordovaActivity" >
|
android:name=".actions.CordovaActivity" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.CordovaDriverAction" >
|
android:name=".actions.CordovaDriverAction" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.errorurl" >
|
android:name=".actions.errorurl" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.fullscreen" >
|
android:name=".actions.fullscreen" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.htmlnotfound" >
|
android:name=".actions.htmlnotfound" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.iframe" >
|
android:name=".actions.iframe" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.lifecycle" >
|
android:name=".actions.lifecycle" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.loading" >
|
android:name=".actions.loading" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.menus" >
|
android:name=".actions.menus" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -189,7 +189,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.splashscreen" >
|
android:name=".actions.splashscreen" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -199,7 +199,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.tests" >
|
android:name=".actions.tests" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.timeout" >
|
android:name=".actions.timeout" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -219,7 +219,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.userwebview" >
|
android:name=".actions.userwebview" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -229,7 +229,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.whitelist" >
|
android:name=".actions.whitelist" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -239,7 +239,7 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.xhr" >
|
android:name=".actions.xhr" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
@@ -249,11 +249,11 @@
|
|||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:name="org.apache.cordova.test.backbuttonmultipage" >
|
android:name=".actions.backbuttonmultipage" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -24,12 +24,11 @@ These tests are designed to verify Android native features and other Android spe
|
|||||||
|
|
||||||
## Initial Setup ##
|
## Initial Setup ##
|
||||||
|
|
||||||
There really isn't any manual setup to do. The ant script takes care of that.
|
Before running the tests, they need to be set up.
|
||||||
You don't even need to compile cordova-x.y.z.jar or copy it, because
|
|
||||||
project.properties has a library reference to ../framework. However, Robotium has to be
|
|
||||||
installed for the onScrollChanged tests to work correctly. It can be found at https://code.google.com/p/robotium/
|
|
||||||
|
|
||||||
To run manually from command line:
|
0. Copy cordova-x.y.z.jar into libs directory
|
||||||
|
|
||||||
|
To run from command line:
|
||||||
|
|
||||||
0. Build by entering `ant debug install`
|
0. Build by entering `ant debug install`
|
||||||
0. Run tests by clicking on "CordovaTest" icon on device
|
0. Run tests by clicking on "CordovaTest" icon on device
|
||||||
@@ -39,7 +38,7 @@ To run from Eclipse:
|
|||||||
0. Import Android project into Eclipse
|
0. Import Android project into Eclipse
|
||||||
0. Ensure Project properties "Java Build Path" includes the lib/cordova-x.y.z.jar
|
0. Ensure Project properties "Java Build Path" includes the lib/cordova-x.y.z.jar
|
||||||
0. Create run configuration if not already created
|
0. Create run configuration if not already created
|
||||||
0. Run As -> Android JUnit Test
|
0. Run tests
|
||||||
|
|
||||||
## Automatic Runs ##
|
## Automatic Runs ##
|
||||||
|
|
||||||
@@ -47,3 +46,5 @@ Once you have installed the test, you can launch and run the tests
|
|||||||
automatically with the below command:
|
automatically with the below command:
|
||||||
|
|
||||||
adb shell am instrument -w org.apache.cordova.test/android.test.InstrumentationTestRunner
|
adb shell am instrument -w org.apache.cordova.test/android.test.InstrumentationTestRunner
|
||||||
|
|
||||||
|
(Optionally, you can also run in Eclipse)
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -27,8 +27,9 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Cordova Android Tests</h1>
|
<h1>Cordova Android Tests</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height"> </span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Page 1</h4>
|
<h4>Page 1</h4>
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -27,8 +27,9 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Cordova Android Tests</h1>
|
<h1>Cordova Android Tests</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height"> </span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Page 2</h4>
|
<h4>Page 2</h4>
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -27,8 +27,9 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Cordova Android Tests</h1>
|
<h1>Cordova Android Tests</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height"> </span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Page 3</h4>
|
<h4>Page 3</h4>
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -40,8 +40,13 @@
|
|||||||
|
|
||||||
function onDeviceReady() {
|
function onDeviceReady() {
|
||||||
// Register the event listener
|
// Register the event listener
|
||||||
document.getElementById("deviceready").innerHTML = "fired";
|
document.getElementById("platform").innerHTML = device.platform;
|
||||||
document.getElementById("cordova").innerHTML = cordova.version;
|
document.getElementById("version").innerHTML = device.version;
|
||||||
|
document.getElementById("uuid").innerHTML = device.uuid;
|
||||||
|
document.getElementById("name").innerHTML = device.name;
|
||||||
|
document.getElementById("width").innerHTML = screen.width;
|
||||||
|
document.getElementById("height").innerHTML = screen.height;
|
||||||
|
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
|
||||||
|
|
||||||
document.addEventListener("pause", onPause, false);
|
document.addEventListener("pause", onPause, false);
|
||||||
document.addEventListener("resume", onResume, false);
|
document.addEventListener("resume", onResume, false);
|
||||||
@@ -79,8 +84,17 @@
|
|||||||
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
|
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
|
||||||
<h1>Events</h1>
|
<h1>Events</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
Platform: <span id="platform"> </span>, Version: <span
|
||||||
|
id="version"> </span>
|
||||||
|
</h4>
|
||||||
|
<h4>
|
||||||
|
UUID: <span id="uuid"> </span>, Name: <span id="name"> </span>
|
||||||
|
</h4>
|
||||||
|
<h4>
|
||||||
|
Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span>
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
Press "Home" button, then return to this app to see pause/resume.<br>
|
Press "Home" button, then return to this app to see pause/resume.<br>
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -40,8 +40,13 @@
|
|||||||
|
|
||||||
function onDeviceReady() {
|
function onDeviceReady() {
|
||||||
// Register the event listener
|
// Register the event listener
|
||||||
document.getElementById("deviceready").innerHTML = "fired";
|
document.getElementById("platform").innerHTML = device.platform;
|
||||||
document.getElementById("cordova").innerHTML = cordova.version;
|
document.getElementById("version").innerHTML = device.version;
|
||||||
|
document.getElementById("uuid").innerHTML = device.uuid;
|
||||||
|
document.getElementById("name").innerHTML = device.name;
|
||||||
|
document.getElementById("width").innerHTML = screen.width;
|
||||||
|
document.getElementById("height").innerHTML = screen.height;
|
||||||
|
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
|
||||||
|
|
||||||
document.addEventListener("pause", onPause, false);
|
document.addEventListener("pause", onPause, false);
|
||||||
document.addEventListener("resume", onResume, false);
|
document.addEventListener("resume", onResume, false);
|
||||||
@@ -79,8 +84,17 @@
|
|||||||
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
|
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
|
||||||
<h1>Events</h1>
|
<h1>Events</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
Platform: <span id="platform"> </span>, Version: <span
|
||||||
|
id="version"> </span>
|
||||||
|
</h4>
|
||||||
|
<h4>
|
||||||
|
UUID: <span id="uuid"> </span>, Name: <span id="name"> </span>
|
||||||
|
</h4>
|
||||||
|
<h4>
|
||||||
|
Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span>
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Press "Back" button to return to Page 1.</h4>
|
<h4>Press "Back" button to return to Page 1.</h4>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -29,8 +29,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Background Color Test</h1>
|
<h1>Background Color Test</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
Before this page was show, you should have seen the background flash green.</br>
|
Before this page was show, you should have seen the background flash green.</br>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -29,8 +29,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Basic Auth</h1>
|
<h1>Basic Auth</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
Loading link below should be successful and show page indicating username=test & password=test. <br>
|
Loading link below should be successful and show page indicating username=test & password=test. <br>
|
||||||
|
|||||||
6878
test/assets/www/cordova.android.js
Normal file
6878
test/assets/www/cordova.android.js
Normal file
File diff suppressed because it is too large
Load Diff
2115
test/assets/www/cordova.js
vendored
Executable file
2115
test/assets/www/cordova.js
vendored
Executable file
File diff suppressed because it is too large
Load Diff
3
test/assets/www/cordova_plugins.js
vendored
3
test/assets/www/cordova_plugins.js
vendored
@@ -1,3 +0,0 @@
|
|||||||
cordova.define('cordova/plugin_list', function(require, exports, module) {
|
|
||||||
module.exports = []
|
|
||||||
});
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -29,8 +29,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Full Screen Test</h1>
|
<h1>Full Screen Test</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
The app should take over the entire screen. <br>
|
The app should take over the entire screen. <br>
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.$
|
under the License.$
|
||||||
-->
|
-->
|
||||||
This is an error page.
|
This is an error page.
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -33,8 +33,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>IFrame</h1>
|
<h1>IFrame</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
Press the two buttons:<br>
|
Press the two buttons:<br>
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -29,8 +29,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>IFrame window</h1>
|
<h1>IFrame window</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
This should display a Cordova page inside an iframe. The info above should be filled out.
|
This should display a Cordova page inside an iframe. The info above should be filled out.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -38,28 +38,31 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Cordova Android Tests</h1>
|
<h1>Cordova Android Tests</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
|
<h4>Cordova Version: <span id="cordova"> </span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Run each of the test activities below:</h4>
|
<h4>Run each of the test activities below:</h4>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.jqmtabbackbutton');">Backbutton jQM tab</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.jqmtabbackbutton');">Backbutton jQM tab</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.backbuttonmultipage');">Backbutton with multiple pages</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.backbuttonmultipage');">Backbutton with multiple pages</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.backgroundcolor');">Background Color</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.backgroundcolor');">Background Color</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.basicauth');">Basic Authentication</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.basicauth');">Basic Authentication</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.errorurl');">Error URL</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.errorurl');">Error URL</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.fullscreen');">Full Screen</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.fullscreen');">Full Screen</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.htmlnotfound');">HTML not found</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.htmlnotfound');">HTML not found</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.iframe');">IFrame</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.iframe');">IFrame</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.lifecycle');">Lifecycle</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.lifecycle');">Lifecycle</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.loading');">Loading indicator</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.loading');">Loading indicator</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.menus');">Menus</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.menus');">Menus</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.background');">No multitasking</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.background');">No multitasking</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.splashscreen');">Splash screen</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.splashscreen');">Splash screen</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.timeout');">Load timeout</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.timeout');">Load timeout</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.userwebview');">User WebView/Client/Chrome</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.userwebview');">User WebView/Client/Chrome</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.whitelist');">Whitelist</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.whitelist');">Whitelist</button>
|
||||||
<button class="btn large" onclick="startActivity('org.apache.cordova.test.xhr');">XHR</button>
|
<button class="btn large" onclick="startActivity('org.apache.cordova.test.actions.xhr');">XHR</button>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -40,8 +40,13 @@
|
|||||||
|
|
||||||
function onDeviceReady() {
|
function onDeviceReady() {
|
||||||
// Register the event listener
|
// Register the event listener
|
||||||
document.getElementById("deviceready").innerHTML = "fired";
|
document.getElementById("platform").innerHTML = device.platform;
|
||||||
document.getElementById("cordova").innerHTML = cordova.version;
|
document.getElementById("version").innerHTML = device.version;
|
||||||
|
document.getElementById("uuid").innerHTML = device.uuid;
|
||||||
|
document.getElementById("name").innerHTML = device.name;
|
||||||
|
document.getElementById("width").innerHTML = screen.width;
|
||||||
|
document.getElementById("height").innerHTML = screen.height;
|
||||||
|
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
|
||||||
|
|
||||||
document.addEventListener("pause", onPause, false);
|
document.addEventListener("pause", onPause, false);
|
||||||
document.addEventListener("resume", onResume, false);
|
document.addEventListener("resume", onResume, false);
|
||||||
@@ -79,8 +84,17 @@
|
|||||||
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
|
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
|
||||||
<h1>Events</h1>
|
<h1>Events</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
Platform: <span id="platform"> </span>, Version: <span
|
||||||
|
id="version"> </span>
|
||||||
|
</h4>
|
||||||
|
<h4>
|
||||||
|
UUID: <span id="uuid"> </span>, Name: <span id="name"> </span>
|
||||||
|
</h4>
|
||||||
|
<h4>
|
||||||
|
Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span>
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Test 1</h4>
|
<h4>Test 1</h4>
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
@@ -40,8 +40,13 @@
|
|||||||
|
|
||||||
function onDeviceReady() {
|
function onDeviceReady() {
|
||||||
// Register the event listener
|
// Register the event listener
|
||||||
document.getElementById("deviceready").innerHTML = "fired";
|
document.getElementById("platform").innerHTML = device.platform;
|
||||||
document.getElementById("cordova").innerHTML = cordova.version;
|
document.getElementById("version").innerHTML = device.version;
|
||||||
|
document.getElementById("uuid").innerHTML = device.uuid;
|
||||||
|
document.getElementById("name").innerHTML = device.name;
|
||||||
|
document.getElementById("width").innerHTML = screen.width;
|
||||||
|
document.getElementById("height").innerHTML = screen.height;
|
||||||
|
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
|
||||||
|
|
||||||
document.addEventListener("pause", onPause, false);
|
document.addEventListener("pause", onPause, false);
|
||||||
document.addEventListener("resume", onResume, false);
|
document.addEventListener("resume", onResume, false);
|
||||||
@@ -79,10 +84,17 @@
|
|||||||
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
|
<body onload="onLoad()" onunload="onUnLoaded()" id="stage" class="theme">
|
||||||
<h1>Events</h1>
|
<h1>Events</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>
|
||||||
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
Platform: <span id="platform"> </span>, Version: <span
|
||||||
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
id="version"> </span>
|
||||||
<h4>Width: <span id="width"> </span>, Height: <span id="height"> </span>, Color Depth: <span id="colorDepth"></span></h4>
|
</h4>
|
||||||
|
<h4>
|
||||||
|
UUID: <span id="uuid"> </span>, Name: <span id="name"> </span>
|
||||||
|
</h4>
|
||||||
|
<h4>
|
||||||
|
Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span>
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
You should see<br>
|
You should see<br>
|
||||||
|
|||||||
@@ -18,8 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var deviceInfo = function() {
|
var deviceInfo = function() {
|
||||||
document.getElementById("deviceready").innerHTML = "fired";
|
document.getElementById("platform").innerHTML = device.platform;
|
||||||
document.getElementById("cordova").innerHTML = cordova.version;
|
document.getElementById("version").innerHTML = device.version;
|
||||||
|
document.getElementById("uuid").innerHTML = device.uuid;
|
||||||
|
document.getElementById("name").innerHTML = device.name;
|
||||||
|
document.getElementById("width").innerHTML = screen.width;
|
||||||
|
document.getElementById("height").innerHTML = screen.height;
|
||||||
|
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
|
||||||
|
var el = document.getElementById("cordova");
|
||||||
|
if (el) {
|
||||||
|
el.innerHTML = device.cordova;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var getLocation = function() {
|
var getLocation = function() {
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -29,8 +29,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Menu Test</h1>
|
<h1>Menu Test</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>The menu items should be:</h4>
|
<h4>The menu items should be:</h4>
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -29,8 +29,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Splash Screen Test</h1>
|
<h1>Splash Screen Test</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
You should have seen the splash screen for 2 seconds.</div>
|
You should have seen the splash screen for 2 seconds.</div>
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -29,8 +29,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>User WebView/Client/Chrome Test</h1>
|
<h1>User WebView/Client/Chrome Test</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>The following should be seen in LogCat:</h4>
|
<h4>The following should be seen in LogCat:</h4>
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -29,8 +29,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Whitelist Page 1</h1>
|
<h1>Whitelist Page 1</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
Loading Page 2 should be successful.<br>
|
Loading Page 2 should be successful.<br>
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -29,8 +29,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>Whitelist Page 2</h1>
|
<h1>Whitelist Page 2</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
Press "backbutton"
|
Press "backbutton"
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one$
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file$
|
||||||
distributed with this work for additional information
|
distributed with this work for additional information$
|
||||||
regarding copyright ownership. The ASF licenses this file
|
regarding copyright ownership. The ASF licenses this file$
|
||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the$
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance$
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at$
|
||||||
|
$
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0$
|
||||||
|
$
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,$
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an$
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY$
|
||||||
KIND, either express or implied. See the License for the
|
KIND, either express or implied. See the License for the$
|
||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations$
|
||||||
under the License.
|
under the License.$
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=320, user-scalable=no" />
|
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
<title>Cordova Tests</title>
|
<title>Cordova Tests</title>
|
||||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
|
||||||
@@ -49,8 +49,10 @@
|
|||||||
<body onload="init();" id="stage" class="theme">
|
<body onload="init();" id="stage" class="theme">
|
||||||
<h1>XHR</h1>
|
<h1>XHR</h1>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
<h4>Cordova: <span id="cordova"> </span></h4>
|
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4>
|
||||||
<h4>Deviceready: <span id="deviceready"> </span></h4>
|
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4>
|
||||||
|
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||||
|
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="info">
|
<div id="info">
|
||||||
Press buttons below to test. You should see an alert with results displayed.
|
Press buttons below to test. You should see an alert with results displayed.
|
||||||
|
|||||||
@@ -66,16 +66,9 @@
|
|||||||
|
|
||||||
<!-- extension targets. Uncomment the ones where you want to do custom work
|
<!-- extension targets. Uncomment the ones where you want to do custom work
|
||||||
in between standard targets -->
|
in between standard targets -->
|
||||||
|
|
||||||
<target name="-pre-build">
|
|
||||||
<!-- copy in the current cordova.js file from the parent project -->
|
|
||||||
<copy file="../framework/assets/www/cordova.js"
|
|
||||||
todir="assets/www"
|
|
||||||
preservelastmodified="true"
|
|
||||||
failonerror="true"
|
|
||||||
verbose="true" />
|
|
||||||
</target>
|
|
||||||
<!--
|
<!--
|
||||||
|
<target name="-pre-build">
|
||||||
|
</target>
|
||||||
<target name="-pre-compile">
|
<target name="-pre-compile">
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var android_sdk_version = require('./lib/android_sdk_version');
|
|
||||||
|
|
||||||
android_sdk_version.run().done(null, function(err) {
|
|
||||||
console.log(err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var build = require('./lib/build'),
|
|
||||||
reqs = require('./lib/check_reqs'),
|
|
||||||
args = process.argv;
|
|
||||||
|
|
||||||
// Support basic help commands
|
|
||||||
if(args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
|
|
||||||
args[2] == 'help' || args[2] == '-help' || args[2] == '/help') {
|
|
||||||
build.help();
|
|
||||||
} else {
|
|
||||||
reqs.run().then(function() {
|
|
||||||
return build.run(args[2]);
|
|
||||||
}).done(null, function(err) {
|
|
||||||
console.error(err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
:: Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
:: or more contributor license agreements. See the NOTICE file
|
|
||||||
:: distributed with this work for additional information
|
|
||||||
:: regarding copyright ownership. The ASF licenses this file
|
|
||||||
:: to you under the Apache License, Version 2.0 (the
|
|
||||||
:: "License"); you may not use this file except in compliance
|
|
||||||
:: with the License. You may obtain a copy of the License at
|
|
||||||
::
|
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
::
|
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
|
||||||
:: software distributed under the License is distributed on an
|
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
:: KIND, either express or implied. See the License for the
|
|
||||||
:: specific language governing permissions and limitations
|
|
||||||
:: under the License.
|
|
||||||
|
|
||||||
@ECHO OFF
|
|
||||||
SET script_path="%~dp0build"
|
|
||||||
IF EXIST %script_path% (
|
|
||||||
node "%script_path%" %*
|
|
||||||
) ELSE (
|
|
||||||
ECHO.
|
|
||||||
ECHO ERROR: Could not find 'build' script in 'cordova' folder, aborting...>&2
|
|
||||||
EXIT /B 1
|
|
||||||
)
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var check_reqs = require('./lib/check_reqs');
|
|
||||||
|
|
||||||
check_reqs.run().done(null, function(err) {
|
|
||||||
console.log(err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var clean = require('./lib/clean'),
|
|
||||||
reqs = require('./lib/check_reqs'),
|
|
||||||
args = process.argv;
|
|
||||||
|
|
||||||
// Usage support for when args are given
|
|
||||||
if(args.length > 2) {
|
|
||||||
clean.help();
|
|
||||||
} else {
|
|
||||||
reqs.run().done(function() {
|
|
||||||
return clean.run();
|
|
||||||
}, function(err) {
|
|
||||||
console.error('ERROR: ' + err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
:: Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
:: or more contributor license agreements. See the NOTICE file
|
|
||||||
:: distributed with this work for additional information
|
|
||||||
:: regarding copyright ownership. The ASF licenses this file
|
|
||||||
:: to you under the Apache License, Version 2.0 (the
|
|
||||||
:: "License"); you may not use this file except in compliance
|
|
||||||
:: with the License. You may obtain a copy of the License at
|
|
||||||
::
|
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
::
|
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
|
||||||
:: software distributed under the License is distributed on an
|
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
:: KIND, either express or implied. See the License for the
|
|
||||||
:: specific language governing permissions and limitations
|
|
||||||
:: under the License.
|
|
||||||
|
|
||||||
@ECHO OFF
|
|
||||||
SET script_path="%~dp0clean"
|
|
||||||
IF EXIST %script_path% (
|
|
||||||
node "%script_path%" %*
|
|
||||||
) ELSE (
|
|
||||||
ECHO.
|
|
||||||
ECHO ERROR: Could not find 'clean' script in 'cordova' folder, aborting...>&2
|
|
||||||
EXIT /B 1
|
|
||||||
)
|
|
||||||
65
test/cordova/lib/android_sdk_version.js
vendored
65
test/cordova/lib/android_sdk_version.js
vendored
@@ -1,65 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
|
||||||
child_process = require('child_process'),
|
|
||||||
Q = require('q');
|
|
||||||
|
|
||||||
get_highest_sdk = function(results){
|
|
||||||
var reg = /\d+/;
|
|
||||||
var apiLevels = [];
|
|
||||||
for(var i=0;i<results.length;i++){
|
|
||||||
apiLevels[i] = parseInt(results[i].match(reg)[0]);
|
|
||||||
}
|
|
||||||
apiLevels.sort(function(a,b){return b-a});
|
|
||||||
console.log(apiLevels[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
get_sdks = function() {
|
|
||||||
var d = Q.defer();
|
|
||||||
child_process.exec('android list targets', function(err, stdout, stderr) {
|
|
||||||
if (err) d.reject(stderr);
|
|
||||||
else d.resolve(stdout);
|
|
||||||
});
|
|
||||||
|
|
||||||
return d.promise.then(function(output) {
|
|
||||||
var reg = /android-\d+/gi;
|
|
||||||
var results = output.match(reg);
|
|
||||||
if(results.length===0){
|
|
||||||
return Q.reject(new Error('No android sdks installed.'));
|
|
||||||
}else{
|
|
||||||
get_highest_sdk(results);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Q();
|
|
||||||
}, function(stderr) {
|
|
||||||
if (stderr.match(/command\snot\sfound/)) {
|
|
||||||
return Q.reject(new Error('The command \"android\" failed. Make sure you have the latest Android SDK installed, and the \"android\" command (inside the tools/ folder) is added to your path.'));
|
|
||||||
} else {
|
|
||||||
return Q.reject(new Error('An error occurred while listing Android targets'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.run = function() {
|
|
||||||
return Q.all([get_sdks()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
41
test/cordova/lib/appinfo.js
vendored
41
test/cordova/lib/appinfo.js
vendored
@@ -1,41 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var path = require('path');
|
|
||||||
var fs = require('fs');
|
|
||||||
var cachedAppInfo = null;
|
|
||||||
|
|
||||||
function readAppInfoFromManifest() {
|
|
||||||
var manifestPath = path.join(__dirname, '..', '..', 'AndroidManifest.xml');
|
|
||||||
var manifestData = fs.readFileSync(manifestPath, {encoding:'utf8'});
|
|
||||||
var packageName = /\bpackage\s*=\s*"(.+?)"/.exec(manifestData);
|
|
||||||
if (!packageName) throw new Error('Could not find package name within ' + manifestPath);
|
|
||||||
var activityTag = /<activity\b[\s\S]*<\/activity>/.exec(manifestData);
|
|
||||||
if (!activityTag) throw new Error('Could not find <activity> within ' + manifestPath);
|
|
||||||
var activityName = /\bandroid:name\s*=\s*"(.+?)"/.exec(activityTag);
|
|
||||||
if (!activityName) throw new Error('Could not find android:name within ' + manifestPath);
|
|
||||||
|
|
||||||
return packageName[1] + '/.' + activityName[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.getActivityName = function() {
|
|
||||||
return cachedAppInfo = cachedAppInfo || readAppInfoFromManifest();
|
|
||||||
};
|
|
||||||
87
test/cordova/lib/build.js
vendored
87
test/cordova/lib/build.js
vendored
@@ -1,87 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
|
||||||
exec = require('./exec'),
|
|
||||||
Q = require('q'),
|
|
||||||
clean = require('./clean'),
|
|
||||||
path = require('path'),
|
|
||||||
fs = require('fs'),
|
|
||||||
ROOT = path.join(__dirname, '..', '..');
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Builds the project with ant.
|
|
||||||
* Returns a promise.
|
|
||||||
*/
|
|
||||||
module.exports.run = function(build_type) {
|
|
||||||
//default build type
|
|
||||||
build_type = typeof build_type !== 'undefined' ? build_type : "--debug";
|
|
||||||
var cmd;
|
|
||||||
switch(build_type) {
|
|
||||||
case '--debug' :
|
|
||||||
cmd = 'ant debug -f ' + path.join(ROOT, 'build.xml');
|
|
||||||
break;
|
|
||||||
case '--release' :
|
|
||||||
cmd = 'ant release -f ' + path.join(ROOT, 'build.xml');
|
|
||||||
break;
|
|
||||||
case '--nobuild' :
|
|
||||||
console.log('Skipping build...');
|
|
||||||
return Q();
|
|
||||||
default :
|
|
||||||
return Q.reject('Build option \'' + build_type + '\' not recognized.');
|
|
||||||
}
|
|
||||||
if(cmd) {
|
|
||||||
return clean.run() // TODO: Can we stop cleaning every time and let ant build incrementally?
|
|
||||||
.then(function() {
|
|
||||||
return exec(cmd);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return Q();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Gets the path to the apk file, if not such file exists then
|
|
||||||
* the script will error out. (should we error or just return undefined?)
|
|
||||||
*/
|
|
||||||
module.exports.get_apk = function() {
|
|
||||||
if(fs.existsSync(path.join(ROOT, 'bin'))) {
|
|
||||||
var bin_files = fs.readdirSync(path.join(ROOT, 'bin'));
|
|
||||||
for (file in bin_files) {
|
|
||||||
if(path.extname(bin_files[file]) == '.apk') {
|
|
||||||
return path.join(ROOT, 'bin', bin_files[file]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.error('ERROR : No .apk found in \'bin\' folder');
|
|
||||||
process.exit(2);
|
|
||||||
} else {
|
|
||||||
console.error('ERROR : unable to find project bin folder, could not locate .apk');
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.help = function() {
|
|
||||||
console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'corodva', 'build')) + ' [build_type]');
|
|
||||||
console.log('Build Types : ');
|
|
||||||
console.log(' \'--debug\': Default build, will build project in using ant debug');
|
|
||||||
console.log(' \'--release\': will build project using ant release');
|
|
||||||
console.log(' \'--nobuild\': will skip build process (can be used with run command)');
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
94
test/cordova/lib/check_reqs.js
vendored
94
test/cordova/lib/check_reqs.js
vendored
@@ -1,94 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
|
||||||
child_process = require('child_process'),
|
|
||||||
Q = require('q'),
|
|
||||||
path = require('path'),
|
|
||||||
fs = require('fs'),
|
|
||||||
ROOT = path.join(__dirname, '..', '..');
|
|
||||||
|
|
||||||
// Get valid target from framework/project.properties
|
|
||||||
module.exports.get_target = function() {
|
|
||||||
if(fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
|
|
||||||
var target = shell.grep(/target=android-[\d+]/, path.join(ROOT, 'framework', 'project.properties'));
|
|
||||||
return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
|
|
||||||
} else if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
|
|
||||||
// if no target found, we're probably in a project and project.properties is in ROOT.
|
|
||||||
var target = shell.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties'));
|
|
||||||
return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a promise.
|
|
||||||
module.exports.check_ant = function() {
|
|
||||||
var d = Q.defer();
|
|
||||||
child_process.exec('ant -version', function(err, stdout, stderr) {
|
|
||||||
if (err) d.reject(new Error('ERROR : executing command \'ant\', make sure you have ant installed and added to your path.'));
|
|
||||||
else d.resolve();
|
|
||||||
});
|
|
||||||
return d.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a promise.
|
|
||||||
module.exports.check_java = function() {
|
|
||||||
if(process.env.JAVA_HOME) {
|
|
||||||
var d = Q.defer();
|
|
||||||
child_process.exec('java -version', function(err, stdout, stderr) {
|
|
||||||
if(err) d.reject(new Error('ERROR : executing command \'java\', make sure you java environment is set up. Including your JDK and JRE.' + err));
|
|
||||||
else d.resolve();
|
|
||||||
});
|
|
||||||
return d.promise;
|
|
||||||
} else {
|
|
||||||
return Q.reject(new Error('ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a promise.
|
|
||||||
module.exports.check_android = function() {
|
|
||||||
var valid_target = this.get_target();
|
|
||||||
var d = Q.defer();
|
|
||||||
child_process.exec('android list targets', function(err, stdout, stderr) {
|
|
||||||
if (err) d.reject(stderr);
|
|
||||||
else d.resolve(stdout);
|
|
||||||
});
|
|
||||||
|
|
||||||
return d.promise.then(function(output) {
|
|
||||||
if (!output.match(valid_target)) {
|
|
||||||
return Q.reject(new Error('Please install Android target ' + valid_target.split('-')[1] + ' (the Android newest SDK). Make sure you have the latest Android tools installed as well. Run \"android\" from your command-line to install/update any missing SDKs or tools.'));
|
|
||||||
}
|
|
||||||
return Q();
|
|
||||||
}, function(stderr) {
|
|
||||||
if (stderr.match(/command\snot\sfound/)) {
|
|
||||||
return Q.reject(new Error('The command \"android\" failed. Make sure you have the latest Android SDK installed, and the \"android\" command (inside the tools/ folder) is added to your path.'));
|
|
||||||
} else {
|
|
||||||
return Q.reject(new Error('An error occurred while listing Android targets'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a promise.
|
|
||||||
module.exports.run = function() {
|
|
||||||
return Q.all([this.check_ant(), this.check_java(), this.check_android()]).then(function() {
|
|
||||||
console.log('Looks like your environment fully supports cordova-android development!');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
38
test/cordova/lib/clean.js
vendored
38
test/cordova/lib/clean.js
vendored
@@ -1,38 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var exec = require('./exec'),
|
|
||||||
path = require('path'),
|
|
||||||
ROOT = path.join(__dirname, '..', '..');
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cleans the project using ant
|
|
||||||
* Returns a promise.
|
|
||||||
*/
|
|
||||||
module.exports.run = function() {
|
|
||||||
return exec('ant clean -f ' + path.join(ROOT, 'build.xml'));
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.help = function() {
|
|
||||||
console.log('Usage: ' + path.relative(process.cwd(), process.argv[1]));
|
|
||||||
console.log('Cleans the project directory.');
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
86
test/cordova/lib/device.js
vendored
86
test/cordova/lib/device.js
vendored
@@ -1,86 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var exec = require('./exec'),
|
|
||||||
Q = require('q'),
|
|
||||||
path = require('path'),
|
|
||||||
build = require('./build'),
|
|
||||||
appinfo = require('./appinfo'),
|
|
||||||
ROOT = path.join(__dirname, '..', '..');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a promise for the list of the device ID's found
|
|
||||||
*/
|
|
||||||
module.exports.list = function() {
|
|
||||||
return exec('adb devices')
|
|
||||||
.then(function(output) {
|
|
||||||
var response = output.split('\n');
|
|
||||||
var device_list = [];
|
|
||||||
for (var i = 1; i < response.length; i++) {
|
|
||||||
if (response[i].match(/\w+\tdevice/) && !response[i].match(/emulator/)) {
|
|
||||||
device_list.push(response[i].replace(/\tdevice/, '').replace('\r', ''));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return device_list;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Installs a previously built application on the device
|
|
||||||
* and launches it.
|
|
||||||
* Returns a promise.
|
|
||||||
*/
|
|
||||||
module.exports.install = function(target) {
|
|
||||||
var launchName;
|
|
||||||
return this.list()
|
|
||||||
.then(function(device_list) {
|
|
||||||
if (!device_list || !device_list.length)
|
|
||||||
return Q.reject('ERROR: Failed to deploy to device, no devices found.');
|
|
||||||
|
|
||||||
// default device
|
|
||||||
target = typeof target !== 'undefined' ? target : device_list[0];
|
|
||||||
|
|
||||||
if (device_list.indexOf(target) < 0)
|
|
||||||
return Q.reject('ERROR: Unable to find target \'' + target + '\'.');
|
|
||||||
|
|
||||||
var apk_path = build.get_apk();
|
|
||||||
launchName = appinfo.getActivityName();
|
|
||||||
console.log('Installing app on device...');
|
|
||||||
var cmd = 'adb -s ' + target + ' install -r ' + apk_path;
|
|
||||||
return exec(cmd);
|
|
||||||
}).then(function(output) {
|
|
||||||
if (output.match(/Failure/)) return Q.reject('ERROR: Failed to install apk to device: ' + output);
|
|
||||||
|
|
||||||
//unlock screen
|
|
||||||
var cmd = 'adb -s ' + target + ' shell input keyevent 82';
|
|
||||||
return exec(cmd);
|
|
||||||
}, function(err) { return Q.reject('ERROR: Failed to install apk to device: ' + err); })
|
|
||||||
.then(function() {
|
|
||||||
// launch the application
|
|
||||||
console.log('Launching application...');
|
|
||||||
var cmd = 'adb -s ' + target + ' shell am start -W -a android.intent.action.MAIN -n ' + launchName;
|
|
||||||
return exec(cmd);
|
|
||||||
}).then(function() {
|
|
||||||
console.log('LANCH SUCCESS');
|
|
||||||
}, function(err) {
|
|
||||||
return Q.reject('ERROR: Failed to launch application on device: ' + err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
330
test/cordova/lib/emulator.js
vendored
330
test/cordova/lib/emulator.js
vendored
@@ -1,330 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
|
||||||
exec = require('./exec'),
|
|
||||||
Q = require('q'),
|
|
||||||
path = require('path'),
|
|
||||||
appinfo = require('./appinfo'),
|
|
||||||
build = require('./build'),
|
|
||||||
ROOT = path.join(__dirname, '..', '..'),
|
|
||||||
child_process = require('child_process'),
|
|
||||||
new_emulator = 'cordova_emulator';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a Promise for a list of emulator images in the form of objects
|
|
||||||
* {
|
|
||||||
name : <emulator_name>,
|
|
||||||
path : <path_to_emulator_image>,
|
|
||||||
target : <api_target>,
|
|
||||||
abi : <cpu>,
|
|
||||||
skin : <skin>
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
module.exports.list_images = function() {
|
|
||||||
return exec('android list avds')
|
|
||||||
.then(function(output) {
|
|
||||||
var response = output.split('\n');
|
|
||||||
var emulator_list = [];
|
|
||||||
for (var i = 1; i < response.length; i++) {
|
|
||||||
// To return more detailed information use img_obj
|
|
||||||
var img_obj = {};
|
|
||||||
if (response[i].match(/Name:\s/)) {
|
|
||||||
img_obj['name'] = response[i].split('Name: ')[1].replace('\r', '');
|
|
||||||
if (response[i + 1].match(/Path:\s/)) {
|
|
||||||
i++;
|
|
||||||
img_obj['path'] = response[i].split('Path: ')[1].replace('\r', '');
|
|
||||||
}
|
|
||||||
if (response[i + 1].match(/\(API\slevel\s/)) {
|
|
||||||
i++;
|
|
||||||
img_obj['target'] = response[i].replace('\r', '');
|
|
||||||
}
|
|
||||||
if (response[i + 1].match(/ABI:\s/)) {
|
|
||||||
i++;
|
|
||||||
img_obj['abi'] = response[i].split('ABI: ')[1].replace('\r', '');
|
|
||||||
}
|
|
||||||
if (response[i + 1].match(/Skin:\s/)) {
|
|
||||||
i++;
|
|
||||||
img_obj['skin'] = response[i].split('Skin: ')[1].replace('\r', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
emulator_list.push(img_obj);
|
|
||||||
}
|
|
||||||
/* To just return a list of names use this
|
|
||||||
if (response[i].match(/Name:\s/)) {
|
|
||||||
emulator_list.push(response[i].split('Name: ')[1].replace('\r', '');
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
|
||||||
return emulator_list;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will return the closest avd to the projects target
|
|
||||||
* or undefined if no avds exist.
|
|
||||||
* Returns a promise.
|
|
||||||
*/
|
|
||||||
module.exports.best_image = function() {
|
|
||||||
var project_target = this.get_target().replace('android-', '');
|
|
||||||
return this.list_images()
|
|
||||||
.then(function(images) {
|
|
||||||
var closest = 9999;
|
|
||||||
var best = images[0];
|
|
||||||
for (i in images) {
|
|
||||||
var target = images[i].target;
|
|
||||||
if(target) {
|
|
||||||
var num = target.split('(API level ')[1].replace(')', '');
|
|
||||||
if (num == project_target) {
|
|
||||||
return images[i];
|
|
||||||
} else if (project_target - num < closest && project_target > num) {
|
|
||||||
var closest = project_target - num;
|
|
||||||
best = images[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return best;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a promise.
|
|
||||||
module.exports.list_started = function() {
|
|
||||||
return exec('adb devices')
|
|
||||||
.then(function(output) {
|
|
||||||
var response = output.split('\n');
|
|
||||||
var started_emulator_list = [];
|
|
||||||
for (var i = 1; i < response.length; i++) {
|
|
||||||
if (response[i].match(/device/) && response[i].match(/emulator/)) {
|
|
||||||
started_emulator_list.push(response[i].replace(/\tdevice/, '').replace('\r', ''));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return started_emulator_list;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.get_target = function() {
|
|
||||||
var target = shell.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties'));
|
|
||||||
return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a promise.
|
|
||||||
module.exports.list_targets = function() {
|
|
||||||
return exec('android list targets')
|
|
||||||
.then(function(output) {
|
|
||||||
var target_out = output.split('\n');
|
|
||||||
var targets = [];
|
|
||||||
for (var i = target_out.length; i >= 0; i--) {
|
|
||||||
if(target_out[i].match(/id:/)) {
|
|
||||||
targets.push(targets[i].split(' ')[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return targets;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Starts an emulator with the given ID,
|
|
||||||
* and returns the started ID of that emulator.
|
|
||||||
* If no ID is given it will used the first image availible,
|
|
||||||
* if no image is availible it will error out (maybe create one?).
|
|
||||||
*
|
|
||||||
* Returns a promise.
|
|
||||||
*/
|
|
||||||
module.exports.start = function(emulator_ID) {
|
|
||||||
var self = this;
|
|
||||||
var emulator_id, num_started, started_emulators;
|
|
||||||
|
|
||||||
return self.list_started()
|
|
||||||
.then(function(list) {
|
|
||||||
started_emulators = list;
|
|
||||||
num_started = started_emulators.length;
|
|
||||||
if (typeof emulator_ID === 'undefined') {
|
|
||||||
return self.list_images()
|
|
||||||
.then(function(emulator_list) {
|
|
||||||
if (emulator_list.length > 0) {
|
|
||||||
return self.best_image()
|
|
||||||
.then(function(best) {
|
|
||||||
emulator_ID = best.name;
|
|
||||||
console.log('WARNING : no emulator specified, defaulting to ' + emulator_ID);
|
|
||||||
return emulator_ID;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return Q.reject('ERROR : No emulator images (avds) found, if you would like to create an\n' +
|
|
||||||
' avd follow the instructions provided here:\n' +
|
|
||||||
' http://developer.android.com/tools/devices/index.html\n' +
|
|
||||||
' Or run \'android create avd --name <name> --target <targetID>\'\n' +
|
|
||||||
' in on the command line.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return Q(emulator_ID);
|
|
||||||
}
|
|
||||||
}).then(function() {
|
|
||||||
var cmd, args;
|
|
||||||
if(process.platform == 'win32' || process.platform == 'win64') {
|
|
||||||
cmd = '%comspec%';
|
|
||||||
args = ['/c', 'start', 'cmd', '/c', 'emulator', '-avd', emulator_ID];
|
|
||||||
} else {
|
|
||||||
cmd = 'emulator';
|
|
||||||
args = ['-avd', emulator_ID];
|
|
||||||
}
|
|
||||||
var proc = child_process.spawn(cmd, args, { stdio: 'inherit', detached: true });
|
|
||||||
proc.unref(); // Don't wait for it to finish, since the emulator will probably keep running for a long time.
|
|
||||||
}).then(function() {
|
|
||||||
// wait for emulator to start
|
|
||||||
console.log('Waiting for emulator...');
|
|
||||||
return self.wait_for_emulator(num_started);
|
|
||||||
}).then(function(new_started) {
|
|
||||||
if (new_started.length > 1) {
|
|
||||||
for (i in new_started) {
|
|
||||||
if (started_emulators.indexOf(new_started[i]) < 0) {
|
|
||||||
emulator_id = new_started[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
emulator_id = new_started[0];
|
|
||||||
}
|
|
||||||
if (!emulator_id) return Q.reject('ERROR : Failed to start emulator, could not find new emulator');
|
|
||||||
|
|
||||||
//wait for emulator to boot up
|
|
||||||
process.stdout.write('Booting up emulator (this may take a while)...');
|
|
||||||
return self.wait_for_boot(emulator_id);
|
|
||||||
}).then(function() {
|
|
||||||
console.log('BOOT COMPLETE');
|
|
||||||
|
|
||||||
//unlock screen
|
|
||||||
return exec('adb -s ' + emulator_id + ' shell input keyevent 82');
|
|
||||||
}).then(function() {
|
|
||||||
//return the new emulator id for the started emulators
|
|
||||||
return emulator_id;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Waits for the new emulator to apear on the started-emulator list.
|
|
||||||
* Returns a promise with a list of newly started emulators' IDs.
|
|
||||||
*/
|
|
||||||
module.exports.wait_for_emulator = function(num_running) {
|
|
||||||
var self = this;
|
|
||||||
return self.list_started()
|
|
||||||
.then(function(new_started) {
|
|
||||||
if (new_started.length > num_running) {
|
|
||||||
return new_started;
|
|
||||||
} else {
|
|
||||||
return Q.delay(1000).then(function() {
|
|
||||||
return self.wait_for_emulator(num_running);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Waits for the boot animation property of the emulator to switch to 'stopped'
|
|
||||||
*/
|
|
||||||
module.exports.wait_for_boot = function(emulator_id) {
|
|
||||||
var self = this;
|
|
||||||
return exec('adb -s ' + emulator_id + ' shell getprop init.svc.bootanim')
|
|
||||||
.then(function(output) {
|
|
||||||
if (output.match(/stopped/)) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
process.stdout.write('.');
|
|
||||||
return Q.delay(3000).then(function() {
|
|
||||||
return self.wait_for_boot(emulator_id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create avd
|
|
||||||
* TODO : Enter the stdin input required to complete the creation of an avd.
|
|
||||||
* Returns a promise.
|
|
||||||
*/
|
|
||||||
module.exports.create_image = function(name, target) {
|
|
||||||
console.log('Creating avd named ' + name);
|
|
||||||
if (target) {
|
|
||||||
return exec('android create avd --name ' + name + ' --target ' + target)
|
|
||||||
.then(null, function(error) {
|
|
||||||
console.error('ERROR : Failed to create emulator image : ');
|
|
||||||
console.error(' Do you have the latest android targets including ' + target + '?');
|
|
||||||
console.error(create.output);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log('WARNING : Project target not found, creating avd with a different target but the project may fail to install.');
|
|
||||||
return exec('android create avd --name ' + name + ' --target ' + this.list_targets()[0])
|
|
||||||
.then(function() {
|
|
||||||
// TODO: This seems like another error case, even though it always happens.
|
|
||||||
console.error('ERROR : Unable to create an avd emulator, no targets found.');
|
|
||||||
console.error('Please insure you have targets availible by runing the "android" command');
|
|
||||||
return Q.reject();
|
|
||||||
}, function(error) {
|
|
||||||
console.error('ERROR : Failed to create emulator image : ');
|
|
||||||
console.error(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Installs a previously built application on the emulator and launches it.
|
|
||||||
* If no target is specified, then it picks one.
|
|
||||||
* If no started emulators are found, error out.
|
|
||||||
* Returns a promise.
|
|
||||||
*/
|
|
||||||
module.exports.install = function(target) {
|
|
||||||
var self = this;
|
|
||||||
return this.list_started()
|
|
||||||
.then(function(emulator_list) {
|
|
||||||
if (emulator_list.length < 1) {
|
|
||||||
return Q.reject('No started emulators found, please start an emultor before deploying your project.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// default emulator
|
|
||||||
target = typeof target !== 'undefined' ? target : emulator_list[0];
|
|
||||||
if (emulator_list.indexOf(target) < 0) {
|
|
||||||
return Q.reject('Unable to find target \'' + target + '\'. Failed to deploy to emulator.');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Installing app on emulator...');
|
|
||||||
var apk_path = build.get_apk();
|
|
||||||
return exec('adb -s ' + target + ' install -r ' + apk_path);
|
|
||||||
}).then(function(output) {
|
|
||||||
if (output.match(/Failure/)) {
|
|
||||||
return Q.reject('Failed to install apk to emulator: ' + output);
|
|
||||||
}
|
|
||||||
return Q();
|
|
||||||
}, function(err) {
|
|
||||||
return Q.reject('Failed to install apk to emulator: ' + err);
|
|
||||||
}).then(function() {
|
|
||||||
//unlock screen
|
|
||||||
return exec('adb -s ' + target + ' shell input keyevent 82');
|
|
||||||
}).then(function() {
|
|
||||||
// launch the application
|
|
||||||
console.log('Launching application...');
|
|
||||||
var launchName = appinfo.getActivityName();
|
|
||||||
cmd = 'adb -s ' + target + ' shell am start -W -a android.intent.action.MAIN -n ' + launchName;
|
|
||||||
return exec(cmd);
|
|
||||||
}).then(function(output) {
|
|
||||||
console.log('LAUNCH SUCCESS');
|
|
||||||
}, function(err) {
|
|
||||||
return Q.reject('Failed to launch app on emulator: ' + err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
43
test/cordova/lib/exec.js
vendored
43
test/cordova/lib/exec.js
vendored
@@ -1,43 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var child_process = require('child_process'),
|
|
||||||
Q = require('q');
|
|
||||||
|
|
||||||
// Takes a command and optional current working directory.
|
|
||||||
// Returns a promise that either resolves with the stdout, or
|
|
||||||
// rejects with an error message and the stderr.
|
|
||||||
module.exports = function(cmd, opt_cwd) {
|
|
||||||
var d = Q.defer();
|
|
||||||
console.log('exec: ' + cmd);
|
|
||||||
try {
|
|
||||||
child_process.exec(cmd, {cwd: opt_cwd}, function(err, stdout, stderr) {
|
|
||||||
console.log([cmd, err, stdout, stderr]);
|
|
||||||
if (err) d.reject('Error executing "' + cmd + '": ' + stderr);
|
|
||||||
else d.resolve(stdout);
|
|
||||||
});
|
|
||||||
} catch(e) {
|
|
||||||
console.error('error caught: ' + e);
|
|
||||||
d.reject(e);
|
|
||||||
}
|
|
||||||
return d.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var device = require('./device'),
|
|
||||||
args = process.argv;
|
|
||||||
|
|
||||||
if(args.length > 2) {
|
|
||||||
var install_target;
|
|
||||||
if (args[2].substring(0, 9) == '--target=') {
|
|
||||||
install_target = args[2].substring(9, args[2].length);
|
|
||||||
device.install(install_target).done(null, function(err) {
|
|
||||||
console.error('ERROR: ' + err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
device.install().done(null, function(err) {
|
|
||||||
console.error('ERROR: ' + err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
:: Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
:: or more contributor license agreements. See the NOTICE file
|
|
||||||
:: distributed with this work for additional information
|
|
||||||
:: regarding copyright ownership. The ASF licenses this file
|
|
||||||
:: to you under the Apache License, Version 2.0 (the
|
|
||||||
:: "License"); you may not use this file except in compliance
|
|
||||||
:: with the License. You may obtain a copy of the License at
|
|
||||||
::
|
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
::
|
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
|
||||||
:: software distributed under the License is distributed on an
|
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
:: KIND, either express or implied. See the License for the
|
|
||||||
:: specific language governing permissions and limitations
|
|
||||||
:: under the License.
|
|
||||||
|
|
||||||
@ECHO OFF
|
|
||||||
SET script_path="%~dp0install-device"
|
|
||||||
IF EXIST %script_path% (
|
|
||||||
node "%script_path%" %*
|
|
||||||
) ELSE (
|
|
||||||
ECHO.
|
|
||||||
ECHO ERROR: Could not find 'install-device' script in 'cordova\lib' folder, aborting...>&2
|
|
||||||
EXIT /B 1
|
|
||||||
)
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var emulator = require('./emulator'),
|
|
||||||
args = process.argv;
|
|
||||||
|
|
||||||
var install_target;
|
|
||||||
if(args.length > 2) {
|
|
||||||
if (args[2].substring(0, 9) == '--target=') {
|
|
||||||
install_target = args[2].substring(9, args[2].length);
|
|
||||||
} else {
|
|
||||||
console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emulator.install(install_target).done(null, function(err) {
|
|
||||||
console.error('ERROR: ' + err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
:: Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
:: or more contributor license agreements. See the NOTICE file
|
|
||||||
:: distributed with this work for additional information
|
|
||||||
:: regarding copyright ownership. The ASF licenses this file
|
|
||||||
:: to you under the Apache License, Version 2.0 (the
|
|
||||||
:: "License"); you may not use this file except in compliance
|
|
||||||
:: with the License. You may obtain a copy of the License at
|
|
||||||
::
|
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
::
|
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
|
||||||
:: software distributed under the License is distributed on an
|
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
:: KIND, either express or implied. See the License for the
|
|
||||||
:: specific language governing permissions and limitations
|
|
||||||
:: under the License.
|
|
||||||
|
|
||||||
@ECHO OFF
|
|
||||||
SET script_path="%~dp0install-emulator"
|
|
||||||
IF EXIST %script_path% (
|
|
||||||
node "%script_path%" %*
|
|
||||||
) ELSE (
|
|
||||||
ECHO.
|
|
||||||
ECHO ERROR: Could not find 'install-emulator' script in 'cordova\lib' folder, aborting...>&2
|
|
||||||
EXIT /B 1
|
|
||||||
)
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var devices = require('./device');
|
|
||||||
|
|
||||||
// Usage support for when args are given
|
|
||||||
devices.list().done(function(device_list) {
|
|
||||||
device_list && device_list.forEach(function(dev) {
|
|
||||||
console.log(dev);
|
|
||||||
});
|
|
||||||
}, function(err) {
|
|
||||||
console.error('ERROR: ' + err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
:: Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
:: or more contributor license agreements. See the NOTICE file
|
|
||||||
:: distributed with this work for additional information
|
|
||||||
:: regarding copyright ownership. The ASF licenses this file
|
|
||||||
:: to you under the Apache License, Version 2.0 (the
|
|
||||||
:: "License"); you may not use this file except in compliance
|
|
||||||
:: with the License. You may obtain a copy of the License at
|
|
||||||
::
|
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
::
|
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
|
||||||
:: software distributed under the License is distributed on an
|
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
:: KIND, either express or implied. See the License for the
|
|
||||||
:: specific language governing permissions and limitations
|
|
||||||
:: under the License.
|
|
||||||
|
|
||||||
@ECHO OFF
|
|
||||||
SET script_path="%~dp0list-devices"
|
|
||||||
IF EXIST %script_path% (
|
|
||||||
node "%script_path%" %*
|
|
||||||
) ELSE (
|
|
||||||
ECHO.
|
|
||||||
ECHO ERROR: Could not find 'list-devices' script in 'cordova\lib' folder, aborting...>&2
|
|
||||||
EXIT /B 1
|
|
||||||
)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var emulators = require('./emulator');
|
|
||||||
|
|
||||||
// Usage support for when args are given
|
|
||||||
emulators.list_images().done(function(emulator_list) {
|
|
||||||
emulator_list && emulator_list.forEach(function(emu) {
|
|
||||||
console.log(emu.name);
|
|
||||||
});
|
|
||||||
}, function(err) {
|
|
||||||
console.error('ERROR: ' + err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
:: Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
:: or more contributor license agreements. See the NOTICE file
|
|
||||||
:: distributed with this work for additional information
|
|
||||||
:: regarding copyright ownership. The ASF licenses this file
|
|
||||||
:: to you under the Apache License, Version 2.0 (the
|
|
||||||
:: "License"); you may not use this file except in compliance
|
|
||||||
:: with the License. You may obtain a copy of the License at
|
|
||||||
::
|
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
::
|
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
|
||||||
:: software distributed under the License is distributed on an
|
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
:: KIND, either express or implied. See the License for the
|
|
||||||
:: specific language governing permissions and limitations
|
|
||||||
:: under the License.
|
|
||||||
|
|
||||||
@ECHO OFF
|
|
||||||
SET script_path="%~dp0list-emulator-images"
|
|
||||||
IF EXIST %script_path% (
|
|
||||||
node "%script_path%" %*
|
|
||||||
) ELSE (
|
|
||||||
ECHO.
|
|
||||||
ECHO ERROR: Could not find 'list-emulator-images' script in 'cordova\lib' folder, aborting...>&2
|
|
||||||
EXIT /B 1
|
|
||||||
)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var emulators = require('./emulator');
|
|
||||||
|
|
||||||
// Usage support for when args are given
|
|
||||||
emulators.list_started().done(function(emulator_list) {
|
|
||||||
emulator_list && emulator_list.forEach(function(emu) {
|
|
||||||
console.log(emu);
|
|
||||||
});
|
|
||||||
}, function(err) {
|
|
||||||
console.error('ERROR: ' + err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
:: Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
:: or more contributor license agreements. See the NOTICE file
|
|
||||||
:: distributed with this work for additional information
|
|
||||||
:: regarding copyright ownership. The ASF licenses this file
|
|
||||||
:: to you under the Apache License, Version 2.0 (the
|
|
||||||
:: "License"); you may not use this file except in compliance
|
|
||||||
:: with the License. You may obtain a copy of the License at
|
|
||||||
::
|
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
::
|
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
|
||||||
:: software distributed under the License is distributed on an
|
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
:: KIND, either express or implied. See the License for the
|
|
||||||
:: specific language governing permissions and limitations
|
|
||||||
:: under the License.
|
|
||||||
|
|
||||||
@ECHO OFF
|
|
||||||
SET script_path="%~dp0list-started-emulators"
|
|
||||||
IF EXIST %script_path% (
|
|
||||||
node "%script_path%" %*
|
|
||||||
) ELSE (
|
|
||||||
ECHO.
|
|
||||||
ECHO ERROR: Could not find 'list-started-emulators' script in 'cordova\lib' folder, aborting...>&2
|
|
||||||
EXIT /B 1
|
|
||||||
)
|
|
||||||
57
test/cordova/lib/log.js
vendored
57
test/cordova/lib/log.js
vendored
@@ -1,57 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
|
||||||
path = require('path'),
|
|
||||||
Q = require('q'),
|
|
||||||
child_process = require('child_process'),
|
|
||||||
ROOT = path.join(__dirname, '..', '..');
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Starts running logcat in the shell.
|
|
||||||
* Returns a promise.
|
|
||||||
*/
|
|
||||||
module.exports.run = function() {
|
|
||||||
var cmd = 'adb logcat | grep -v nativeGetEnabledTags';
|
|
||||||
var d = Q.defer();
|
|
||||||
var adb = child_process.spawn('adb', ['logcat']);
|
|
||||||
|
|
||||||
adb.stdout.on('data', function(data) {
|
|
||||||
var lines = data ? data.toString().split('\n') : [];
|
|
||||||
var out = lines.filter(function(x) { return x.indexOf('nativeGetEnabledTags') < 0; });
|
|
||||||
console.log(out.join('\n'));
|
|
||||||
});
|
|
||||||
|
|
||||||
adb.stderr.on('data', console.error);
|
|
||||||
adb.on('close', function(code) {
|
|
||||||
if (code > 0) {
|
|
||||||
d.reject('Failed to run logcat command.');
|
|
||||||
} else d.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
return d.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.help = function() {
|
|
||||||
console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'corodva', 'log')));
|
|
||||||
console.log('Gives the logcat output on the command line.');
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
139
test/cordova/lib/run.js
vendored
139
test/cordova/lib/run.js
vendored
@@ -1,139 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var path = require('path'),
|
|
||||||
build = require('./build'),
|
|
||||||
emulator = require('./emulator'),
|
|
||||||
device = require('./device'),
|
|
||||||
Q = require('q');
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Runs the application on a device if availible.
|
|
||||||
* If not device is found, it will use a started emulator.
|
|
||||||
* If no started emulators are found it will attempt to start an avd.
|
|
||||||
* If no avds are found it will error out.
|
|
||||||
* Returns a promise.
|
|
||||||
*/
|
|
||||||
module.exports.run = function(args) {
|
|
||||||
var build_type;
|
|
||||||
var install_target;
|
|
||||||
|
|
||||||
for (var i=2; i<args.length; i++) {
|
|
||||||
if (args[i] == '--debug') {
|
|
||||||
build_type = '--debug';
|
|
||||||
} else if (args[i] == '--release') {
|
|
||||||
build_type = '--release';
|
|
||||||
} else if (args[i] == '--nobuild') {
|
|
||||||
build_type = '--nobuild';
|
|
||||||
} else if (args[i] == '--device') {
|
|
||||||
install_target = '--device';
|
|
||||||
} else if (args[i] == '--emulator') {
|
|
||||||
install_target = '--emulator';
|
|
||||||
} else if (args[i].substring(0, 9) == '--target=') {
|
|
||||||
install_target = args[i].substring(9, args[i].length);
|
|
||||||
} else {
|
|
||||||
console.error('ERROR : Run option \'' + args[i] + '\' not recognized.');
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return build.run(build_type).then(function() {
|
|
||||||
if (install_target == '--device') {
|
|
||||||
return device.install();
|
|
||||||
} else if (install_target == '--emulator') {
|
|
||||||
return emulator.list_started().then(function(started) {
|
|
||||||
var p = started && started.length > 0 ? Q() : emulator.start();
|
|
||||||
return p.then(function() { emulator.install(); });
|
|
||||||
});
|
|
||||||
} else if (install_target) {
|
|
||||||
var devices, started_emulators, avds;
|
|
||||||
return device.list()
|
|
||||||
.then(function(res) {
|
|
||||||
devices = res;
|
|
||||||
return emulator.list_started();
|
|
||||||
}).then(function(res) {
|
|
||||||
started_emulators = res;
|
|
||||||
return emulator.list_images();
|
|
||||||
}).then(function(res) {
|
|
||||||
avds = res;
|
|
||||||
if (devices.indexOf(install_target) > -1) {
|
|
||||||
return device.install(install_target);
|
|
||||||
} else if (started_emulators.indexOf(install_target) > -1) {
|
|
||||||
return emulator.install(install_target);
|
|
||||||
} else {
|
|
||||||
// if target emulator isn't started, then start it.
|
|
||||||
var emulator_ID;
|
|
||||||
for(avd in avds) {
|
|
||||||
if(avds[avd].name == install_target) {
|
|
||||||
return emulator.start(install_target)
|
|
||||||
.then(function() { emulator.install(emulator_ID); });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Q.reject('Target \'' + install_target + '\' not found, unable to run project');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// no target given, deploy to device if availible, otherwise use the emulator.
|
|
||||||
return device.list()
|
|
||||||
.then(function(device_list) {
|
|
||||||
if (device_list.length > 0) {
|
|
||||||
console.log('WARNING : No target specified, deploying to device \'' + device_list[0] + '\'.');
|
|
||||||
return device.install(device_list[0]);
|
|
||||||
} else {
|
|
||||||
return emulator.list_started()
|
|
||||||
.then(function(emulator_list) {
|
|
||||||
if (emulator_list.length > 0) {
|
|
||||||
console.log('WARNING : No target specified, deploying to emulator \'' + emulator_list[0] + '\'.');
|
|
||||||
return emulator.install(emulator_list[0]);
|
|
||||||
} else {
|
|
||||||
console.log('WARNING : No started emulators found, starting an emulator.');
|
|
||||||
return emulator.best_image()
|
|
||||||
.then(function(best_avd) {
|
|
||||||
if(best_avd) {
|
|
||||||
return emulator.start(best_avd.name)
|
|
||||||
.then(function(emulator_ID) {
|
|
||||||
console.log('WARNING : No target specified, deploying to emulator \'' + emulator_ID + '\'.');
|
|
||||||
return emulator.install(emulator_ID);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return emulator.start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.help = function() {
|
|
||||||
console.log('Usage: ' + path.relative(process.cwd(), args[0]) + ' [options]');
|
|
||||||
console.log('Build options :');
|
|
||||||
console.log(' --debug : Builds project in debug mode');
|
|
||||||
console.log(' --release : Builds project in release mode');
|
|
||||||
console.log(' --nobuild : Runs the currently built project without recompiling');
|
|
||||||
console.log('Deploy options :');
|
|
||||||
console.log(' --device : Will deploy the built project to a device');
|
|
||||||
console.log(' --emulator : Will deploy the built project to an emulator if one exists');
|
|
||||||
console.log(' --target=<target_id> : Installs to the target with the specified id.');
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var emulator = require('./emulator'),
|
|
||||||
args = process.argv;
|
|
||||||
|
|
||||||
var install_target;
|
|
||||||
if(args.length > 2) {
|
|
||||||
if (args[2].substring(0, 9) == '--target=') {
|
|
||||||
install_target = args[2].substring(9, args[2].length);
|
|
||||||
} else {
|
|
||||||
console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emulator.start(install_target).done(null, function(err) {
|
|
||||||
console.error('ERROR: ' + err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
:: Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
:: or more contributor license agreements. See the NOTICE file
|
|
||||||
:: distributed with this work for additional information
|
|
||||||
:: regarding copyright ownership. The ASF licenses this file
|
|
||||||
:: to you under the Apache License, Version 2.0 (the
|
|
||||||
:: "License"); you may not use this file except in compliance
|
|
||||||
:: with the License. You may obtain a copy of the License at
|
|
||||||
::
|
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
::
|
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
|
||||||
:: software distributed under the License is distributed on an
|
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
:: KIND, either express or implied. See the License for the
|
|
||||||
:: specific language governing permissions and limitations
|
|
||||||
:: under the License.
|
|
||||||
|
|
||||||
@ECHO OFF
|
|
||||||
SET script_path="%~dp0start-emulator"
|
|
||||||
IF EXIST %script_path% (
|
|
||||||
node "%script_path%" %*
|
|
||||||
) ELSE (
|
|
||||||
ECHO.
|
|
||||||
ECHO ERROR: Could not find 'start-emulator' script in 'cordova\lib' folder, aborting...>&2
|
|
||||||
EXIT /B 1
|
|
||||||
)
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/*
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var log = require('./lib/log'),
|
|
||||||
reqs = require('./lib/check_reqs'),
|
|
||||||
args = process.argv;
|
|
||||||
|
|
||||||
// Usage support for when args are given
|
|
||||||
if(args.length > 2) {
|
|
||||||
log.help();
|
|
||||||
} else {
|
|
||||||
reqs.run().done(function() {
|
|
||||||
return log.run();
|
|
||||||
}, function(err) {
|
|
||||||
console.error('ERROR: ' + err);
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
:: Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
:: or more contributor license agreements. See the NOTICE file
|
|
||||||
:: distributed with this work for additional information
|
|
||||||
:: regarding copyright ownership. The ASF licenses this file
|
|
||||||
:: to you under the Apache License, Version 2.0 (the
|
|
||||||
:: "License"); you may not use this file except in compliance
|
|
||||||
:: with the License. You may obtain a copy of the License at
|
|
||||||
::
|
|
||||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
::
|
|
||||||
:: Unless required by applicable law or agreed to in writing,
|
|
||||||
:: software distributed under the License is distributed on an
|
|
||||||
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
:: KIND, either express or implied. See the License for the
|
|
||||||
:: specific language governing permissions and limitations
|
|
||||||
:: under the License.
|
|
||||||
|
|
||||||
@ECHO OFF
|
|
||||||
SET script_path="%~dp0log"
|
|
||||||
IF EXIST %script_path% (
|
|
||||||
node "%script_path%" %*
|
|
||||||
) ELSE (
|
|
||||||
ECHO.
|
|
||||||
ECHO ERROR: Could not find 'log' script in 'cordova' folder, aborting...>&2
|
|
||||||
EXIT /B 1
|
|
||||||
)
|
|
||||||
1
test/cordova/node_modules/.bin/shjs
generated
vendored
1
test/cordova/node_modules/.bin/shjs
generated
vendored
@@ -1 +0,0 @@
|
|||||||
../shelljs/bin/shjs
|
|
||||||
40
test/cordova/node_modules/q/CONTRIBUTING.md
generated
vendored
40
test/cordova/node_modules/q/CONTRIBUTING.md
generated
vendored
@@ -1,40 +0,0 @@
|
|||||||
|
|
||||||
For pull requests:
|
|
||||||
|
|
||||||
- Be consistent with prevalent style and design decisions.
|
|
||||||
- Add a Jasmine spec to `specs/q-spec.js`.
|
|
||||||
- Use `npm test` to avoid regressions.
|
|
||||||
- Run tests in `q-spec/run.html` in as many supported browsers as you
|
|
||||||
can find the will to deal with.
|
|
||||||
- Do not build minified versions; we do this each release.
|
|
||||||
- If you would be so kind, add a note to `CHANGES.md` in an
|
|
||||||
appropriate section:
|
|
||||||
|
|
||||||
- `Next Major Version` if it introduces backward incompatibilities
|
|
||||||
to code in the wild using documented features.
|
|
||||||
- `Next Minor Version` if it adds a new feature.
|
|
||||||
- `Next Patch Version` if it fixes a bug.
|
|
||||||
|
|
||||||
For releases:
|
|
||||||
|
|
||||||
- Run `npm test`.
|
|
||||||
- Run tests in `q-spec/run.html` in a representative sample of every
|
|
||||||
browser under the sun.
|
|
||||||
- Run `npm run cover` and make sure you're happy with the results.
|
|
||||||
- Run `npm run minify` and be sure to commit the resulting `q.min.js`.
|
|
||||||
- Note the Gzipped size output by the previous command, and update
|
|
||||||
`README.md` if it has changed to 1 significant digit.
|
|
||||||
- Stash any local changes.
|
|
||||||
- Update `CHANGES.md` to reflect all changes in the differences
|
|
||||||
between `HEAD` and the previous tagged version. Give credit where
|
|
||||||
credit is due.
|
|
||||||
- Update `README.md` to address all new, non-experimental features.
|
|
||||||
- Update the API reference on the Wiki to reflect all non-experimental
|
|
||||||
features.
|
|
||||||
- Use `npm version major|minor|patch` to update `package.json`,
|
|
||||||
commit, and tag the new version.
|
|
||||||
- Use `npm publish` to send up a new release.
|
|
||||||
- Send an email to the q-continuum mailing list announcing the new
|
|
||||||
release and the notes from the change log. This helps folks
|
|
||||||
maintaining other package ecosystems.
|
|
||||||
|
|
||||||
19
test/cordova/node_modules/q/LICENSE
generated
vendored
19
test/cordova/node_modules/q/LICENSE
generated
vendored
@@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
Copyright 2009–2012 Kristopher Michael Kowal. All rights reserved.
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to
|
|
||||||
deal in the Software without restriction, including without limitation the
|
|
||||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
IN THE SOFTWARE.
|
|
||||||
813
test/cordova/node_modules/q/README.md
generated
vendored
813
test/cordova/node_modules/q/README.md
generated
vendored
@@ -1,813 +0,0 @@
|
|||||||
[](http://travis-ci.org/kriskowal/q)
|
|
||||||
|
|
||||||
<a href="http://promises-aplus.github.com/promises-spec">
|
|
||||||
<img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png"
|
|
||||||
align="right" alt="Promises/A+ logo" />
|
|
||||||
</a>
|
|
||||||
|
|
||||||
If a function cannot return a value or throw an exception without
|
|
||||||
blocking, it can return a promise instead. A promise is an object
|
|
||||||
that represents the return value or the thrown exception that the
|
|
||||||
function may eventually provide. A promise can also be used as a
|
|
||||||
proxy for a [remote object][Q-Connection] to overcome latency.
|
|
||||||
|
|
||||||
[Q-Connection]: https://github.com/kriskowal/q-connection
|
|
||||||
|
|
||||||
On the first pass, promises can mitigate the “[Pyramid of
|
|
||||||
Doom][POD]”: the situation where code marches to the right faster
|
|
||||||
than it marches forward.
|
|
||||||
|
|
||||||
[POD]: http://calculist.org/blog/2011/12/14/why-coroutines-wont-work-on-the-web/
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
step1(function (value1) {
|
|
||||||
step2(value1, function(value2) {
|
|
||||||
step3(value2, function(value3) {
|
|
||||||
step4(value3, function(value4) {
|
|
||||||
// Do something with value4
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
With a promise library, you can flatten the pyramid.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
Q.fcall(promisedStep1)
|
|
||||||
.then(promisedStep2)
|
|
||||||
.then(promisedStep3)
|
|
||||||
.then(promisedStep4)
|
|
||||||
.then(function (value4) {
|
|
||||||
// Do something with value4
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
// Handle any error from all above steps
|
|
||||||
})
|
|
||||||
.done();
|
|
||||||
```
|
|
||||||
|
|
||||||
With this approach, you also get implicit error propagation, just like `try`,
|
|
||||||
`catch`, and `finally`. An error in `promisedStep1` will flow all the way to
|
|
||||||
the `catch` function, where it’s caught and handled. (Here `promisedStepN` is
|
|
||||||
a version of `stepN` that returns a promise.)
|
|
||||||
|
|
||||||
The callback approach is called an “inversion of control”.
|
|
||||||
A function that accepts a callback instead of a return value
|
|
||||||
is saying, “Don’t call me, I’ll call you.”. Promises
|
|
||||||
[un-invert][IOC] the inversion, cleanly separating the input
|
|
||||||
arguments from control flow arguments. This simplifies the
|
|
||||||
use and creation of API’s, particularly variadic,
|
|
||||||
rest and spread arguments.
|
|
||||||
|
|
||||||
[IOC]: http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript
|
|
||||||
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
The Q module can be loaded as:
|
|
||||||
|
|
||||||
- A ``<script>`` tag (creating a ``Q`` global variable): ~2.5 KB minified and
|
|
||||||
gzipped.
|
|
||||||
- A Node.js and CommonJS module, available in [npm](https://npmjs.org/) as
|
|
||||||
the [q](https://npmjs.org/package/q) package
|
|
||||||
- An AMD module
|
|
||||||
- A [component](https://github.com/component/component) as ``microjs/q``
|
|
||||||
- Using [bower](http://bower.io/) as ``q``
|
|
||||||
- Using [NuGet](http://nuget.org/) as [Q](https://nuget.org/packages/q)
|
|
||||||
|
|
||||||
Q can exchange promises with jQuery, Dojo, When.js, WinJS, and more.
|
|
||||||
|
|
||||||
## Resources
|
|
||||||
|
|
||||||
Our [wiki][] contains a number of useful resources, including:
|
|
||||||
|
|
||||||
- A method-by-method [Q API reference][reference].
|
|
||||||
- A growing [examples gallery][examples], showing how Q can be used to make
|
|
||||||
everything better. From XHR to database access to accessing the Flickr API,
|
|
||||||
Q is there for you.
|
|
||||||
- There are many libraries that produce and consume Q promises for everything
|
|
||||||
from file system/database access or RPC to templating. For a list of some of
|
|
||||||
the more popular ones, see [Libraries][].
|
|
||||||
- If you want materials that introduce the promise concept generally, and the
|
|
||||||
below tutorial isn't doing it for you, check out our collection of
|
|
||||||
[presentations, blog posts, and podcasts][resources].
|
|
||||||
- A guide for those [coming from jQuery's `$.Deferred`][jquery].
|
|
||||||
|
|
||||||
We'd also love to have you join the Q-Continuum [mailing list][].
|
|
||||||
|
|
||||||
[wiki]: https://github.com/kriskowal/q/wiki
|
|
||||||
[reference]: https://github.com/kriskowal/q/wiki/API-Reference
|
|
||||||
[examples]: https://github.com/kriskowal/q/wiki/Examples-Gallery
|
|
||||||
[Libraries]: https://github.com/kriskowal/q/wiki/Libraries
|
|
||||||
[resources]: https://github.com/kriskowal/q/wiki/General-Promise-Resources
|
|
||||||
[jquery]: https://github.com/kriskowal/q/wiki/Coming-from-jQuery
|
|
||||||
[mailing list]: https://groups.google.com/forum/#!forum/q-continuum
|
|
||||||
|
|
||||||
|
|
||||||
## Tutorial
|
|
||||||
|
|
||||||
Promises have a ``then`` method, which you can use to get the eventual
|
|
||||||
return value (fulfillment) or thrown exception (rejection).
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
promiseMeSomething()
|
|
||||||
.then(function (value) {
|
|
||||||
}, function (reason) {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
If ``promiseMeSomething`` returns a promise that gets fulfilled later
|
|
||||||
with a return value, the first function (the fulfillment handler) will be
|
|
||||||
called with the value. However, if the ``promiseMeSomething`` function
|
|
||||||
gets rejected later by a thrown exception, the second function (the
|
|
||||||
rejection handler) will be called with the exception.
|
|
||||||
|
|
||||||
Note that resolution of a promise is always asynchronous: that is, the
|
|
||||||
fulfillment or rejection handler will always be called in the next turn of the
|
|
||||||
event loop (i.e. `process.nextTick` in Node). This gives you a nice
|
|
||||||
guarantee when mentally tracing the flow of your code, namely that
|
|
||||||
``then`` will always return before either handler is executed.
|
|
||||||
|
|
||||||
In this tutorial, we begin with how to consume and work with promises. We'll
|
|
||||||
talk about how to create them, and thus create functions like
|
|
||||||
`promiseMeSomething` that return promises, [below](#the-beginning).
|
|
||||||
|
|
||||||
|
|
||||||
### Propagation
|
|
||||||
|
|
||||||
The ``then`` method returns a promise, which in this example, I’m
|
|
||||||
assigning to ``outputPromise``.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var outputPromise = getInputPromise()
|
|
||||||
.then(function (input) {
|
|
||||||
}, function (reason) {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
The ``outputPromise`` variable becomes a new promise for the return
|
|
||||||
value of either handler. Since a function can only either return a
|
|
||||||
value or throw an exception, only one handler will ever be called and it
|
|
||||||
will be responsible for resolving ``outputPromise``.
|
|
||||||
|
|
||||||
- If you return a value in a handler, ``outputPromise`` will get
|
|
||||||
fulfilled.
|
|
||||||
|
|
||||||
- If you throw an exception in a handler, ``outputPromise`` will get
|
|
||||||
rejected.
|
|
||||||
|
|
||||||
- If you return a **promise** in a handler, ``outputPromise`` will
|
|
||||||
“become” that promise. Being able to become a new promise is useful
|
|
||||||
for managing delays, combining results, or recovering from errors.
|
|
||||||
|
|
||||||
If the ``getInputPromise()`` promise gets rejected and you omit the
|
|
||||||
rejection handler, the **error** will go to ``outputPromise``:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var outputPromise = getInputPromise()
|
|
||||||
.then(function (value) {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
If the input promise gets fulfilled and you omit the fulfillment handler, the
|
|
||||||
**value** will go to ``outputPromise``:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var outputPromise = getInputPromise()
|
|
||||||
.then(null, function (error) {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Q promises provide a ``fail`` shorthand for ``then`` when you are only
|
|
||||||
interested in handling the error:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var outputPromise = getInputPromise()
|
|
||||||
.fail(function (error) {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
If you are writing JavaScript for modern engines only or using
|
|
||||||
CoffeeScript, you may use `catch` instead of `fail`.
|
|
||||||
|
|
||||||
Promises also have a ``fin`` function that is like a ``finally`` clause.
|
|
||||||
The final handler gets called, with no arguments, when the promise
|
|
||||||
returned by ``getInputPromise()`` either returns a value or throws an
|
|
||||||
error. The value returned or error thrown by ``getInputPromise()``
|
|
||||||
passes directly to ``outputPromise`` unless the final handler fails, and
|
|
||||||
may be delayed if the final handler returns a promise.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var outputPromise = getInputPromise()
|
|
||||||
.fin(function () {
|
|
||||||
// close files, database connections, stop servers, conclude tests
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
- If the handler returns a value, the value is ignored
|
|
||||||
- If the handler throws an error, the error passes to ``outputPromise``
|
|
||||||
- If the handler returns a promise, ``outputPromise`` gets postponed. The
|
|
||||||
eventual value or error has the same effect as an immediate return
|
|
||||||
value or thrown error: a value would be ignored, an error would be
|
|
||||||
forwarded.
|
|
||||||
|
|
||||||
If you are writing JavaScript for modern engines only or using
|
|
||||||
CoffeeScript, you may use `finally` instead of `fin`.
|
|
||||||
|
|
||||||
### Chaining
|
|
||||||
|
|
||||||
There are two ways to chain promises. You can chain promises either
|
|
||||||
inside or outside handlers. The next two examples are equivalent.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return getUsername()
|
|
||||||
.then(function (username) {
|
|
||||||
return getUser(username)
|
|
||||||
.then(function (user) {
|
|
||||||
// if we get here without an error,
|
|
||||||
// the value returned here
|
|
||||||
// or the exception thrown here
|
|
||||||
// resolves the promise returned
|
|
||||||
// by the first line
|
|
||||||
})
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return getUsername()
|
|
||||||
.then(function (username) {
|
|
||||||
return getUser(username);
|
|
||||||
})
|
|
||||||
.then(function (user) {
|
|
||||||
// if we get here without an error,
|
|
||||||
// the value returned here
|
|
||||||
// or the exception thrown here
|
|
||||||
// resolves the promise returned
|
|
||||||
// by the first line
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
The only difference is nesting. It’s useful to nest handlers if you
|
|
||||||
need to capture multiple input values in your closure.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
function authenticate() {
|
|
||||||
return getUsername()
|
|
||||||
.then(function (username) {
|
|
||||||
return getUser(username);
|
|
||||||
})
|
|
||||||
// chained because we will not need the user name in the next event
|
|
||||||
.then(function (user) {
|
|
||||||
return getPassword()
|
|
||||||
// nested because we need both user and password next
|
|
||||||
.then(function (password) {
|
|
||||||
if (user.passwordHash !== hash(password)) {
|
|
||||||
throw new Error("Can't authenticate");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Combination
|
|
||||||
|
|
||||||
You can turn an array of promises into a promise for the whole,
|
|
||||||
fulfilled array using ``all``.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.all([
|
|
||||||
eventualAdd(2, 2),
|
|
||||||
eventualAdd(10, 20)
|
|
||||||
]);
|
|
||||||
```
|
|
||||||
|
|
||||||
If you have a promise for an array, you can use ``spread`` as a
|
|
||||||
replacement for ``then``. The ``spread`` function “spreads” the
|
|
||||||
values over the arguments of the fulfillment handler. The rejection handler
|
|
||||||
will get called at the first sign of failure. That is, whichever of
|
|
||||||
the recived promises fails first gets handled by the rejection handler.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
function eventualAdd(a, b) {
|
|
||||||
return Q.spread([a, b], function (a, b) {
|
|
||||||
return a + b;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
But ``spread`` calls ``all`` initially, so you can skip it in chains.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return getUsername()
|
|
||||||
.then(function (username) {
|
|
||||||
return [username, getUser(username)];
|
|
||||||
})
|
|
||||||
.spread(function (username, user) {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
The ``all`` function returns a promise for an array of values. When this
|
|
||||||
promise is fulfilled, the array contains the fulfillment values of the original
|
|
||||||
promises, in the same order as those promises. If one of the given promises
|
|
||||||
is rejected, the returned promise is immediately rejected, not waiting for the
|
|
||||||
rest of the batch. If you want to wait for all of the promises to either be
|
|
||||||
fulfilled or rejected, you can use ``allSettled``.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
Q.allSettled(promises)
|
|
||||||
.then(function (results) {
|
|
||||||
results.forEach(function (result) {
|
|
||||||
if (result.state === "fulfilled") {
|
|
||||||
var value = result.value;
|
|
||||||
} else {
|
|
||||||
var reason = result.reason;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Sequences
|
|
||||||
|
|
||||||
If you have a number of promise-producing functions that need
|
|
||||||
to be run sequentially, you can of course do so manually:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return foo(initialVal).then(bar).then(baz).then(qux);
|
|
||||||
```
|
|
||||||
|
|
||||||
However, if you want to run a dynamically constructed sequence of
|
|
||||||
functions, you'll want something like this:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var funcs = [foo, bar, baz, qux];
|
|
||||||
|
|
||||||
var result = Q(initialVal);
|
|
||||||
funcs.forEach(function (f) {
|
|
||||||
result = result.then(f);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
```
|
|
||||||
|
|
||||||
You can make this slightly more compact using `reduce`:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return funcs.reduce(function (soFar, f) {
|
|
||||||
return soFar.then(f);
|
|
||||||
}, Q(initialVal));
|
|
||||||
```
|
|
||||||
|
|
||||||
Or, you could use th ultra-compact version:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return funcs.reduce(Q.when, Q());
|
|
||||||
```
|
|
||||||
|
|
||||||
### Handling Errors
|
|
||||||
|
|
||||||
One sometimes-unintuive aspect of promises is that if you throw an
|
|
||||||
exception in the fulfillment handler, it will not be be caught by the error
|
|
||||||
handler.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return foo()
|
|
||||||
.then(function (value) {
|
|
||||||
throw new Error("Can't bar.");
|
|
||||||
}, function (error) {
|
|
||||||
// We only get here if "foo" fails
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
To see why this is, consider the parallel between promises and
|
|
||||||
``try``/``catch``. We are ``try``-ing to execute ``foo()``: the error
|
|
||||||
handler represents a ``catch`` for ``foo()``, while the fulfillment handler
|
|
||||||
represents code that happens *after* the ``try``/``catch`` block.
|
|
||||||
That code then needs its own ``try``/``catch`` block.
|
|
||||||
|
|
||||||
In terms of promises, this means chaining your rejection handler:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return foo()
|
|
||||||
.then(function (value) {
|
|
||||||
throw new Error("Can't bar.");
|
|
||||||
})
|
|
||||||
.fail(function (error) {
|
|
||||||
// We get here with either foo's error or bar's error
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### Progress Notification
|
|
||||||
|
|
||||||
It's possible for promises to report their progress, e.g. for tasks that take a
|
|
||||||
long time like a file upload. Not all promises will implement progress
|
|
||||||
notifications, but for those that do, you can consume the progress values using
|
|
||||||
a third parameter to ``then``:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return uploadFile()
|
|
||||||
.then(function () {
|
|
||||||
// Success uploading the file
|
|
||||||
}, function (err) {
|
|
||||||
// There was an error, and we get the reason for error
|
|
||||||
}, function (progress) {
|
|
||||||
// We get notified of the upload's progress as it is executed
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Like `fail`, Q also provides a shorthand for progress callbacks
|
|
||||||
called `progress`:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return uploadFile().progress(function (progress) {
|
|
||||||
// We get notified of the upload's progress
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### The End
|
|
||||||
|
|
||||||
When you get to the end of a chain of promises, you should either
|
|
||||||
return the last promise or end the chain. Since handlers catch
|
|
||||||
errors, it’s an unfortunate pattern that the exceptions can go
|
|
||||||
unobserved.
|
|
||||||
|
|
||||||
So, either return it,
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return foo()
|
|
||||||
.then(function () {
|
|
||||||
return "bar";
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Or, end it.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
foo()
|
|
||||||
.then(function () {
|
|
||||||
return "bar";
|
|
||||||
})
|
|
||||||
.done();
|
|
||||||
```
|
|
||||||
|
|
||||||
Ending a promise chain makes sure that, if an error doesn’t get
|
|
||||||
handled before the end, it will get rethrown and reported.
|
|
||||||
|
|
||||||
This is a stopgap. We are exploring ways to make unhandled errors
|
|
||||||
visible without any explicit handling.
|
|
||||||
|
|
||||||
|
|
||||||
### The Beginning
|
|
||||||
|
|
||||||
Everything above assumes you get a promise from somewhere else. This
|
|
||||||
is the common case. Every once in a while, you will need to create a
|
|
||||||
promise from scratch.
|
|
||||||
|
|
||||||
#### Using ``Q.fcall``
|
|
||||||
|
|
||||||
You can create a promise from a value using ``Q.fcall``. This returns a
|
|
||||||
promise for 10.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.fcall(function () {
|
|
||||||
return 10;
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use ``fcall`` to get a promise for an exception.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.fcall(function () {
|
|
||||||
throw new Error("Can't do it");
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
As the name implies, ``fcall`` can call functions, or even promised
|
|
||||||
functions. This uses the ``eventualAdd`` function above to add two
|
|
||||||
numbers.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.fcall(eventualAdd, 2, 2);
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### Using Deferreds
|
|
||||||
|
|
||||||
If you have to interface with asynchronous functions that are callback-based
|
|
||||||
instead of promise-based, Q provides a few shortcuts (like ``Q.nfcall`` and
|
|
||||||
friends). But much of the time, the solution will be to use *deferreds*.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var deferred = Q.defer();
|
|
||||||
FS.readFile("foo.txt", "utf-8", function (error, text) {
|
|
||||||
if (error) {
|
|
||||||
deferred.reject(new Error(error));
|
|
||||||
} else {
|
|
||||||
deferred.resolve(text);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return deferred.promise;
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that a deferred can be resolved with a value or a promise. The
|
|
||||||
``reject`` function is a shorthand for resolving with a rejected
|
|
||||||
promise.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// this:
|
|
||||||
deferred.reject(new Error("Can't do it"));
|
|
||||||
|
|
||||||
// is shorthand for:
|
|
||||||
var rejection = Q.fcall(function () {
|
|
||||||
throw new Error("Can't do it");
|
|
||||||
});
|
|
||||||
deferred.resolve(rejection);
|
|
||||||
```
|
|
||||||
|
|
||||||
This is a simplified implementation of ``Q.delay``.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
function delay(ms) {
|
|
||||||
var deferred = Q.defer();
|
|
||||||
setTimeout(deferred.resolve, ms);
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This is a simplified implementation of ``Q.timeout``
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
function timeout(promise, ms) {
|
|
||||||
var deferred = Q.defer();
|
|
||||||
Q.when(promise, deferred.resolve);
|
|
||||||
delay(ms).then(function () {
|
|
||||||
deferred.reject(new Error("Timed out"));
|
|
||||||
});
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Finally, you can send a progress notification to the promise with
|
|
||||||
``deferred.notify``.
|
|
||||||
|
|
||||||
For illustration, this is a wrapper for XML HTTP requests in the browser. Note
|
|
||||||
that a more [thorough][XHR] implementation would be in order in practice.
|
|
||||||
|
|
||||||
[XHR]: https://github.com/montagejs/mr/blob/71e8df99bb4f0584985accd6f2801ef3015b9763/browser.js#L29-L73
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
function requestOkText(url) {
|
|
||||||
var request = new XMLHttpRequest();
|
|
||||||
var deferred = Q.defer();
|
|
||||||
|
|
||||||
request.open("GET", url, true);
|
|
||||||
request.onload = onload;
|
|
||||||
request.onerror = onerror;
|
|
||||||
request.onprogress = onprogress;
|
|
||||||
request.send();
|
|
||||||
|
|
||||||
function onload() {
|
|
||||||
if (request.status === 200) {
|
|
||||||
deferred.resolve(request.responseText);
|
|
||||||
} else {
|
|
||||||
deferred.reject(new Error("Status code was " + request.status));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onerror() {
|
|
||||||
deferred.reject(new Error("Can't XHR " + JSON.stringify(url)));
|
|
||||||
}
|
|
||||||
|
|
||||||
function onprogress(event) {
|
|
||||||
deferred.notify(event.loaded / event.total);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Below is an example of how to use this ``requestOkText`` function:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
requestOkText("http://localhost:3000")
|
|
||||||
.then(function (responseText) {
|
|
||||||
// If the HTTP response returns 200 OK, log the response text.
|
|
||||||
console.log(responseText);
|
|
||||||
}, function (error) {
|
|
||||||
// If there's an error or a non-200 status code, log the error.
|
|
||||||
console.error(error);
|
|
||||||
}, function (progress) {
|
|
||||||
// Log the progress as it comes in.
|
|
||||||
console.log("Request progress: " + Math.round(progress * 100) + "%");
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### The Middle
|
|
||||||
|
|
||||||
If you are using a function that may return a promise, but just might
|
|
||||||
return a value if it doesn’t need to defer, you can use the “static”
|
|
||||||
methods of the Q library.
|
|
||||||
|
|
||||||
The ``when`` function is the static equivalent for ``then``.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.when(valueOrPromise, function (value) {
|
|
||||||
}, function (error) {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
All of the other methods on a promise have static analogs with the
|
|
||||||
same name.
|
|
||||||
|
|
||||||
The following are equivalent:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.all([a, b]);
|
|
||||||
```
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.fcall(function () {
|
|
||||||
return [a, b];
|
|
||||||
})
|
|
||||||
.all();
|
|
||||||
```
|
|
||||||
|
|
||||||
When working with promises provided by other libraries, you should
|
|
||||||
convert it to a Q promise. Not all promise libraries make the same
|
|
||||||
guarantees as Q and certainly don’t provide all of the same methods.
|
|
||||||
Most libraries only provide a partially functional ``then`` method.
|
|
||||||
This thankfully is all we need to turn them into vibrant Q promises.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q($.ajax(...))
|
|
||||||
.then(function () {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
If there is any chance that the promise you receive is not a Q promise
|
|
||||||
as provided by your library, you should wrap it using a Q function.
|
|
||||||
You can even use ``Q.invoke`` as a shorthand.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.invoke($, 'ajax', ...)
|
|
||||||
.then(function () {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Over the Wire
|
|
||||||
|
|
||||||
A promise can serve as a proxy for another object, even a remote
|
|
||||||
object. There are methods that allow you to optimistically manipulate
|
|
||||||
properties or call functions. All of these interactions return
|
|
||||||
promises, so they can be chained.
|
|
||||||
|
|
||||||
```
|
|
||||||
direct manipulation using a promise as a proxy
|
|
||||||
-------------------------- -------------------------------
|
|
||||||
value.foo promise.get("foo")
|
|
||||||
value.foo = value promise.put("foo", value)
|
|
||||||
delete value.foo promise.del("foo")
|
|
||||||
value.foo(...args) promise.post("foo", [args])
|
|
||||||
value.foo(...args) promise.invoke("foo", ...args)
|
|
||||||
value(...args) promise.fapply([args])
|
|
||||||
value(...args) promise.fcall(...args)
|
|
||||||
```
|
|
||||||
|
|
||||||
If the promise is a proxy for a remote object, you can shave
|
|
||||||
round-trips by using these functions instead of ``then``. To take
|
|
||||||
advantage of promises for remote objects, check out [Q-Connection][].
|
|
||||||
|
|
||||||
[Q-Connection]: https://github.com/kriskowal/q-connection
|
|
||||||
|
|
||||||
Even in the case of non-remote objects, these methods can be used as
|
|
||||||
shorthand for particularly-simple fulfillment handlers. For example, you
|
|
||||||
can replace
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.fcall(function () {
|
|
||||||
return [{ foo: "bar" }, { foo: "baz" }];
|
|
||||||
})
|
|
||||||
.then(function (value) {
|
|
||||||
return value[0].foo;
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
with
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.fcall(function () {
|
|
||||||
return [{ foo: "bar" }, { foo: "baz" }];
|
|
||||||
})
|
|
||||||
.get(0)
|
|
||||||
.get("foo");
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Adapting Node
|
|
||||||
|
|
||||||
If you're working with functions that make use of the Node.js callback pattern,
|
|
||||||
where callbacks are in the form of `function(err, result)`, Q provides a few
|
|
||||||
useful utility functions for converting between them. The most straightforward
|
|
||||||
are probably `Q.nfcall` and `Q.nfapply` ("Node function call/apply") for calling
|
|
||||||
Node.js-style functions and getting back a promise:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.nfcall(FS.readFile, "foo.txt", "utf-8");
|
|
||||||
return Q.nfapply(FS.readFile, ["foo.txt", "utf-8"]);
|
|
||||||
```
|
|
||||||
|
|
||||||
If you are working with methods, instead of simple functions, you can easily
|
|
||||||
run in to the usual problems where passing a method to another function—like
|
|
||||||
`Q.nfcall`—"un-binds" the method from its owner. To avoid this, you can either
|
|
||||||
use `Function.prototype.bind` or some nice shortcut methods we provide:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
return Q.ninvoke(redisClient, "get", "user:1:id");
|
|
||||||
return Q.npost(redisClient, "get", ["user:1:id"]);
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also create reusable wrappers with `Q.denodeify` or `Q.nbind`:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var readFile = Q.denodeify(FS.readFile);
|
|
||||||
return readFile("foo.txt", "utf-8");
|
|
||||||
|
|
||||||
var redisClientGet = Q.nbind(redisClient.get, redisClient);
|
|
||||||
return redisClientGet("user:1:id");
|
|
||||||
```
|
|
||||||
|
|
||||||
Finally, if you're working with raw deferred objects, there is a
|
|
||||||
`makeNodeResolver` method on deferreds that can be handy:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var deferred = Q.defer();
|
|
||||||
FS.readFile("foo.txt", "utf-8", deferred.makeNodeResolver());
|
|
||||||
return deferred.promise;
|
|
||||||
```
|
|
||||||
|
|
||||||
### Long Stack Traces
|
|
||||||
|
|
||||||
Q comes with optional support for “long stack traces,” wherein the `stack`
|
|
||||||
property of `Error` rejection reasons is rewritten to be traced along
|
|
||||||
asynchronous jumps instead of stopping at the most recent one. As an example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
function theDepthsOfMyProgram() {
|
|
||||||
Q.delay(100).done(function explode() {
|
|
||||||
throw new Error("boo!");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
theDepthsOfMyProgram();
|
|
||||||
```
|
|
||||||
|
|
||||||
usually would give a rather unhelpful stack trace looking something like
|
|
||||||
|
|
||||||
```
|
|
||||||
Error: boo!
|
|
||||||
at explode (/path/to/test.js:3:11)
|
|
||||||
at _fulfilled (/path/to/test.js:q:54)
|
|
||||||
at resolvedValue.promiseDispatch.done (/path/to/q.js:823:30)
|
|
||||||
at makePromise.promise.promiseDispatch (/path/to/q.js:496:13)
|
|
||||||
at pending (/path/to/q.js:397:39)
|
|
||||||
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
|
|
||||||
```
|
|
||||||
|
|
||||||
But, if you turn this feature on by setting
|
|
||||||
|
|
||||||
```js
|
|
||||||
Q.longStackSupport = true;
|
|
||||||
```
|
|
||||||
|
|
||||||
then the above code gives a nice stack trace to the tune of
|
|
||||||
|
|
||||||
```
|
|
||||||
Error: boo!
|
|
||||||
at explode (/path/to/test.js:3:11)
|
|
||||||
From previous event:
|
|
||||||
at theDepthsOfMyProgram (/path/to/test.js:2:16)
|
|
||||||
at Object.<anonymous> (/path/to/test.js:7:1)
|
|
||||||
```
|
|
||||||
|
|
||||||
Note how you can see the the function that triggered the async operation in the
|
|
||||||
stack trace! This is very helpful for debugging, as otherwise you end up getting
|
|
||||||
only the first line, plus a bunch of Q internals, with no sign of where the
|
|
||||||
operation started.
|
|
||||||
|
|
||||||
This feature does come with somewhat-serious performance and memory overhead,
|
|
||||||
however. If you're working with lots of promises, or trying to scale a server
|
|
||||||
to many users, you should probably keep it off. But in development, go for it!
|
|
||||||
|
|
||||||
## Tests
|
|
||||||
|
|
||||||
You can view the results of the Q test suite [in your browser][tests]!
|
|
||||||
|
|
||||||
[tests]: https://rawgithub.com/kriskowal/q/master/spec/q-spec.html
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Copyright 2009–2013 Kristopher Michael Kowal
|
|
||||||
MIT License (enclosed)
|
|
||||||
|
|
||||||
71
test/cordova/node_modules/q/benchmark/compare-with-callbacks.js
generated
vendored
71
test/cordova/node_modules/q/benchmark/compare-with-callbacks.js
generated
vendored
@@ -1,71 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
var Q = require("../q");
|
|
||||||
var fs = require("fs");
|
|
||||||
|
|
||||||
suite("A single simple async operation", function () {
|
|
||||||
bench("with an immediately-fulfilled promise", function (done) {
|
|
||||||
Q().then(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
bench("with direct setImmediate usage", function (done) {
|
|
||||||
setImmediate(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
bench("with direct setTimeout(…, 0)", function (done) {
|
|
||||||
setTimeout(done, 0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
suite("A fs.readFile", function () {
|
|
||||||
var denodeified = Q.denodeify(fs.readFile);
|
|
||||||
|
|
||||||
set("iterations", 1000);
|
|
||||||
set("delay", 1000);
|
|
||||||
|
|
||||||
bench("directly, with callbacks", function (done) {
|
|
||||||
fs.readFile(__filename, done);
|
|
||||||
});
|
|
||||||
|
|
||||||
bench("with Q.nfcall", function (done) {
|
|
||||||
Q.nfcall(fs.readFile, __filename).then(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
bench("with a Q.denodeify'ed version", function (done) {
|
|
||||||
denodeified(__filename).then(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
bench("with manual usage of deferred.makeNodeResolver", function (done) {
|
|
||||||
var deferred = Q.defer();
|
|
||||||
fs.readFile(__filename, deferred.makeNodeResolver());
|
|
||||||
deferred.promise.then(done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
suite("1000 operations in parallel", function () {
|
|
||||||
function makeCounter(desiredCount, ultimateCallback) {
|
|
||||||
var soFar = 0;
|
|
||||||
return function () {
|
|
||||||
if (++soFar === desiredCount) {
|
|
||||||
ultimateCallback();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
var numberOfOps = 1000;
|
|
||||||
|
|
||||||
bench("with immediately-fulfilled promises", function (done) {
|
|
||||||
var counter = makeCounter(numberOfOps, done);
|
|
||||||
|
|
||||||
for (var i = 0; i < numberOfOps; ++i) {
|
|
||||||
Q().then(counter);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
bench("with direct setImmediate usage", function (done) {
|
|
||||||
var counter = makeCounter(numberOfOps, done);
|
|
||||||
|
|
||||||
for (var i = 0; i < numberOfOps; ++i) {
|
|
||||||
setImmediate(counter);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
36
test/cordova/node_modules/q/benchmark/scenarios.js
generated
vendored
36
test/cordova/node_modules/q/benchmark/scenarios.js
generated
vendored
@@ -1,36 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
var Q = require("../q");
|
|
||||||
|
|
||||||
suite("Chaining", function () {
|
|
||||||
var numberToChain = 1000;
|
|
||||||
|
|
||||||
bench("Chaining many already-fulfilled promises together", function (done) {
|
|
||||||
var currentPromise = Q();
|
|
||||||
for (var i = 0; i < numberToChain; ++i) {
|
|
||||||
currentPromise = currentPromise.then(function () {
|
|
||||||
return Q();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
currentPromise.then(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
bench("Chaining and then fulfilling the end of the chain", function (done) {
|
|
||||||
var deferred = Q.defer();
|
|
||||||
|
|
||||||
var currentPromise = deferred.promise;
|
|
||||||
for (var i = 0; i < numberToChain; ++i) {
|
|
||||||
(function () {
|
|
||||||
var promiseToReturn = currentPromise;
|
|
||||||
currentPromise = Q().then(function () {
|
|
||||||
return promiseToReturn;
|
|
||||||
});
|
|
||||||
}());
|
|
||||||
}
|
|
||||||
|
|
||||||
currentPromise.then(done);
|
|
||||||
|
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
93
test/cordova/node_modules/q/package.json
generated
vendored
93
test/cordova/node_modules/q/package.json
generated
vendored
File diff suppressed because one or more lines are too long
1937
test/cordova/node_modules/q/q.js
generated
vendored
1937
test/cordova/node_modules/q/q.js
generated
vendored
File diff suppressed because it is too large
Load Diff
35
test/cordova/node_modules/q/queue.js
generated
vendored
35
test/cordova/node_modules/q/queue.js
generated
vendored
@@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
var Q = require("./q");
|
|
||||||
|
|
||||||
module.exports = Queue;
|
|
||||||
function Queue() {
|
|
||||||
var ends = Q.defer();
|
|
||||||
var closed = Q.defer();
|
|
||||||
return {
|
|
||||||
put: function (value) {
|
|
||||||
var next = Q.defer();
|
|
||||||
ends.resolve({
|
|
||||||
head: value,
|
|
||||||
tail: next.promise
|
|
||||||
});
|
|
||||||
ends.resolve = next.resolve;
|
|
||||||
},
|
|
||||||
get: function () {
|
|
||||||
var result = ends.promise.get("head");
|
|
||||||
ends.promise = ends.promise.get("tail");
|
|
||||||
return result.fail(function (error) {
|
|
||||||
closed.resolve(error);
|
|
||||||
throw error;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
closed: closed.promise,
|
|
||||||
close: function (error) {
|
|
||||||
error = error || new Error("Can't get value from closed queue");
|
|
||||||
var end = {head: Q.reject(error)};
|
|
||||||
end.tail = end;
|
|
||||||
ends.resolve(end);
|
|
||||||
return closed.promise;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
6
test/cordova/node_modules/shelljs/.documentup.json
generated
vendored
6
test/cordova/node_modules/shelljs/.documentup.json
generated
vendored
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ShellJS",
|
|
||||||
"twitter": [
|
|
||||||
"r2r"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
7
test/cordova/node_modules/shelljs/.jshintrc
generated
vendored
7
test/cordova/node_modules/shelljs/.jshintrc
generated
vendored
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"loopfunc": true,
|
|
||||||
"sub": true,
|
|
||||||
"undef": true,
|
|
||||||
"unused": true,
|
|
||||||
"node": true
|
|
||||||
}
|
|
||||||
2
test/cordova/node_modules/shelljs/.npmignore
generated
vendored
2
test/cordova/node_modules/shelljs/.npmignore
generated
vendored
@@ -1,2 +0,0 @@
|
|||||||
test/
|
|
||||||
tmp/
|
|
||||||
5
test/cordova/node_modules/shelljs/.travis.yml
generated
vendored
5
test/cordova/node_modules/shelljs/.travis.yml
generated
vendored
@@ -1,5 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- "0.8"
|
|
||||||
- "0.10"
|
|
||||||
- "0.11"
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user