Merge branch '3.0.0'
diff --git a/Gruntfile.js b/Gruntfile.js
index 3b9ca4e..81275ad 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -120,7 +120,7 @@
grunt.registerTask('test', 'Runs test in node', function() {
var done = this.async();
- require('./test/runner').node();
+ require('./test/runner').node(done);
});
grunt.registerTask('btest', 'Runs tests in the browser', function() {
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index efa3729..dda4d4a 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -22,8 +22,6 @@
var cordova = require('cordova'),
plugins = {
'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
- 'Capture' : require('cordova/plugin/blackberry10/capture'),
- 'Media': require('cordova/plugin/blackberry10/media'),
'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
};
diff --git a/lib/blackberry10/plugin/blackberry10/capture.js b/lib/blackberry10/plugin/blackberry10/capture.js
deleted file mode 100644
index 3c8f1cb..0000000
--- a/lib/blackberry10/plugin/blackberry10/capture.js
+++ /dev/null
@@ -1,76 +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.
- *
-*/
-
-var cordova = require('cordova');
-
-function capture(action, win, fail) {
- var noop = function () {};
-
- blackberry.invoke.card.invokeCamera(action, function (path) {
- var sb = blackberry.io.sandbox;
- blackberry.io.sandbox = false;
- window.webkitRequestFileSystem(window.PERSISTENT, 1024, function (fs) {
- fs.root.getFile(path, {}, function (fe) {
- fe.file(function (file) {
- file.fullPath = fe.fullPath;
- win([file]);
- blackberry.io.sandbox = sb;
- }, fail);
- }, fail);
- }, fail);
- }, noop, noop);
-}
-
-module.exports = {
- getSupportedAudioModes: function (args, win, fail) {
- return {"status": cordova.callbackStatus.OK, "message": []};
- },
- getSupportedImageModes: function (args, win, fail) {
- return {"status": cordova.callbackStatus.OK, "message": []};
- },
- getSupportedVideoModes: function (args, win, fail) {
- return {"status": cordova.callbackStatus.OK, "message": []};
- },
- captureImage: function (args, win, fail) {
- if (args[0].limit > 0) {
- capture("photo", win, fail);
- }
- else {
- win([]);
- }
-
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
- },
- captureVideo: function (args, win, fail) {
- if (args[0].limit > 0) {
- capture("video", win, fail);
- }
- else {
- win([]);
- }
-
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
- },
- captureAudio: function (args, win, fail) {
- fail("Capturing Audio not supported");
- return {"status": cordova.callbackStatus.NO_RESULT, "message": "WebWorks Is On It"};
- }
-};
diff --git a/lib/common/argscheck.js b/lib/common/argscheck.js
index 524b435..5d0cbe7 100644
--- a/lib/common/argscheck.js
+++ b/lib/common/argscheck.js
@@ -63,7 +63,7 @@
if (errMsg) {
errMsg += ', but got ' + typeName + '.';
errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
- // Don't log when running jake test.
+ // Don't log when running unit tests.
if (typeof jasmine == 'undefined') {
console.error(errMsg);
}
diff --git a/lib/ios/exec.js b/lib/ios/exec.js
index 7023c06..93269c5 100644
--- a/lib/ios/exec.js
+++ b/lib/ios/exec.js
@@ -151,7 +151,7 @@
actionArgs = Array.prototype.splice.call(arguments, 1);
console.log('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' +
- "cordova.exec(null, null, \"" + service + "\", " + action + "\"," + JSON.stringify(actionArgs) + ");"
+ "cordova.exec(null, null, \"" + service + "\", \"" + action + "\"," + JSON.stringify(actionArgs) + ");"
);
return;
} catch (e) {
diff --git a/lib/scripts/plugin_loader.js b/lib/scripts/plugin_loader.js
index 892bd76..d9bea0a 100644
--- a/lib/scripts/plugin_loader.js
+++ b/lib/scripts/plugin_loader.js
@@ -34,11 +34,21 @@
}
}
+ function scriptErrorCallback(err) {
+ // Open Question: If a script path specified in cordova_plugins.js does not exist, do we fail for all?
+ // this is currently just continuing.
+ scriptCounter--;
+ if (scriptCounter === 0) {
+ onScriptLoadingComplete && onScriptLoadingComplete();
+ }
+ }
+
// Helper function to inject a <script> tag.
function injectScript(path) {
scriptCounter++;
var script = document.createElement("script");
script.onload = scriptLoadedCallback;
+ script.onerror = scriptErrorCallback;
script.src = path;
document.head.appendChild(script);
}
@@ -50,10 +60,10 @@
context.cordova.require('cordova/channel').onPluginsReady.fire();
}
- // Handler for the cordova_plugins.json content.
+ // Handler for the cordova_plugins.js content.
// See plugman's plugin_loader.js for the details of this object.
// This function is only called if the really is a plugins array that isn't empty.
- // Otherwise the XHR response handler will just call finishPluginLoading().
+ // Otherwise the onerror response handler will just call finishPluginLoading().
function handlePluginsObject(modules, path) {
// First create the callback for when all plugins are loaded.
var mapper = context.cordova.require('cordova/modulemapper');
@@ -61,26 +71,31 @@
// Loop through all the plugins and then through their clobbers and merges.
for (var i = 0; i < modules.length; i++) {
var module = modules[i];
- if (!module) continue;
+ if (module) {
+ try {
+ if (module.clobbers && module.clobbers.length) {
+ for (var j = 0; j < module.clobbers.length; j++) {
+ mapper.clobbers(module.id, module.clobbers[j]);
+ }
+ }
- if (module.clobbers && module.clobbers.length) {
- for (var j = 0; j < module.clobbers.length; j++) {
- mapper.clobbers(module.id, module.clobbers[j]);
+ if (module.merges && module.merges.length) {
+ for (var k = 0; k < module.merges.length; k++) {
+ mapper.merges(module.id, module.merges[k]);
+ }
+ }
+
+ // Finally, if runs is truthy we want to simply require() the module.
+ // This can be skipped if it had any merges or clobbers, though,
+ // since the mapper will already have required the module.
+ if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
+ context.cordova.require(module.id);
+ }
}
- }
-
- if (module.merges && module.merges.length) {
- for (var k = 0; k < module.merges.length; k++) {
- mapper.merges(module.id, module.merges[k]);
+ catch(err) {
+ // error with module, most likely clobbers, should we continue?
}
}
-
- // Finally, if runs is truthy we want to simply require() the module.
- // This can be skipped if it had any merges or clobbers, though,
- // since the mapper will already have required the module.
- if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
- context.cordova.require(module.id);
- }
}
finishPluginLoading();
@@ -103,6 +118,33 @@
break;
}
}
+
+ var plugins_json = path + 'cordova_plugins.json';
+ var plugins_js = path + 'cordova_plugins.js';
+
+ // One some phones (Windows) this xhr.open throws an Access Denied exception
+ // So lets keep trying, but with a script tag injection technique instead of XHR
+ var injectPluginScript = function injectPluginScript() {
+ try {
+ var script = document.createElement("script");
+ script.onload = function(){
+ var list = cordova.require("cordova/plugin_list");
+ handlePluginsObject(list,path);
+ };
+ script.onerror = function() {
+ // Error loading cordova_plugins.js, file not found or something
+ // this is an acceptable error, pre-3.0.0, so we just move on.
+ finishPluginLoading();
+ };
+ script.src = plugins_js;
+ document.head.appendChild(script);
+
+ } catch(err){
+ finishPluginLoading();
+ }
+ }
+
+
// Try to XHR the cordova_plugins.json file asynchronously.
var xhr = new XMLHttpRequest();
xhr.onload = function() {
@@ -121,14 +163,16 @@
}
};
xhr.onerror = function() {
- finishPluginLoading();
+ // In this case, the json file was not present, but XHR was allowed,
+ // so we should still try the script injection technique with the js file
+ // in case that is there.
+ injectPluginScript();
};
- var plugins_json = path + 'cordova_plugins.json';
try { // we commented we were going to try, so let us actually try and catch
xhr.open('GET', plugins_json, true); // Async
xhr.send();
} catch(err){
- finishPluginLoading();
+ injectPluginScript();
}
}(window));
diff --git a/lib/tizen/plugin/globalization/symbols.js b/lib/tizen/plugin/globalization/symbols.js
new file mode 100644
index 0000000..24e6ac5
--- /dev/null
+++ b/lib/tizen/plugin/globalization/symbols.js
@@ -0,0 +1,24 @@
+/*
+ * 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 modulemapper = require('cordova/modulemapper');
+
+modulemapper.merges('cordova/plugin/tizen/Globalization', 'navigator.globalization');
diff --git a/lib/tizen/plugin/splashscreen/symbol.js b/lib/tizen/plugin/splashscreen/symbol.js
new file mode 100644
index 0000000..54eac85
--- /dev/null
+++ b/lib/tizen/plugin/splashscreen/symbol.js
@@ -0,0 +1,24 @@
+/*
+ * 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 modulemapper = require('cordova/modulemapper');
+
+modulemapper.merges('cordova/plugin/tizen/SplashScreen', 'splashscreen'); /// is that correct??? PPL
diff --git a/lib/tizen/plugin/tizen/Globalization.js b/lib/tizen/plugin/tizen/Globalization.js
new file mode 100644
index 0000000..aa7f94a
--- /dev/null
+++ b/lib/tizen/plugin/tizen/Globalization.js
@@ -0,0 +1,495 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+
+/*global tizen:false */
+
+var argscheck = require('cordova/argscheck'),
+ exec = require('cordova/exec'),
+ GlobalizationError = require('cordova/plugin/GlobalizationError');
+
+var globalization = {
+
+/**
+* Returns the string identifier for the client's current language.
+* It returns the language identifier string to the successCB callback with a
+* properties object as a parameter. If there is an error getting the language,
+* then the errorCB callback is invoked.
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.value {String}: The language identifier
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getPreferredLanguage(function (language) {alert('language:' + language.value + '\n');},
+* function () {});
+*/
+getPreferredLanguage:function(successCB, failureCB) {
+ console.log('exec(successCB, failureCB, "Globalization","getPreferredLanguage", []);');
+
+ tizen.systeminfo.getPropertyValue (
+ "LOCALE",
+ function (localeInfo) {
+ console.log("Cordova, getLocaleName, language is " + localeInfo.language);
+ successCB( {"value": localeInfo.language});
+ },
+ function(error) {
+ console.log("Cordova, getLocaleName, An error occurred " + error.message);
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "cannot retrieve language name"));
+ }
+ );
+},
+
+/**
+* Returns the string identifier for the client's current locale setting.
+* It returns the locale identifier string to the successCB callback with a
+* properties object as a parameter. If there is an error getting the locale,
+* then the errorCB callback is invoked.
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.value {String}: The locale identifier
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getLocaleName(function (locale) {alert('locale:' + locale.value + '\n');},
+* function () {});
+*/
+getLocaleName:function(successCB, failureCB) {
+ tizen.systeminfo.getPropertyValue (
+ "LOCALE",
+ function (localeInfo) {
+ console.log("Cordova, getLocaleName, locale name (country) is " + localeInfo.country);
+ successCB( {"value":localeInfo.language});
+ },
+ function(error) {
+ console.log("Cordova, getLocaleName, An error occurred " + error.message);
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "cannot retrieve locale name"));
+ }
+ );
+},
+
+
+/**
+* Returns a date formatted as a string according to the client's user preferences and
+* calendar using the time zone of the client. It returns the formatted date string to the
+* successCB callback with a properties object as a parameter. If there is an error
+* formatting the date, then the errorCB callback is invoked.
+*
+* The defaults are: formatLenght="short" and selector="date and time"
+*
+* @param {Date} date
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* formatLength {String}: 'short', 'medium', 'long', or 'full'
+* selector {String}: 'date', 'time', or 'date and time'
+*
+* @return Object.value {String}: The localized date string
+*
+* @error GlobalizationError.FORMATTING_ERROR
+*
+* Example
+* globalization.dateToString(new Date(),
+* function (date) {alert('date:' + date.value + '\n');},
+* function (errorCode) {alert(errorCode);},
+* {formatLength:'short'});
+*/
+dateToString:function(date, successCB, failureCB, options) {
+ var dateValue = date.valueOf();
+ console.log('exec(successCB, failureCB, "Globalization", "dateToString", [{"date": dateValue, "options": options}]);');
+
+ var tzdate = null;
+ var format = null;
+
+ tzdate = new tizen.TZDate(date);
+
+ if (tzdate) {
+ if (options && (options.formatLength == 'short') ){
+ format = tzdate.toLocaleDateString();
+ }
+ else{
+ format = tzdate.toLocaleString();
+ }
+ console.log('Cordova, globalization, dateToString ' +format);
+ }
+
+ if (format)
+ {
+ successCB ({"value": format});
+ }
+ else {
+ failureCB(new GlobalizationError(GlobalizationError.FORMATTING_ERROR , "cannot format date string"));
+ }
+},
+
+
+/**
+* Parses a date formatted as a string according to the client's user
+* preferences and calendar using the time zone of the client and returns
+* the corresponding date object. It returns the date to the successCB
+* callback with a properties object as a parameter. If there is an error
+* parsing the date string, then the errorCB callback is invoked.
+*
+* The defaults are: formatLength="short" and selector="date and time"
+*
+* @param {String} dateString
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* formatLength {String}: 'short', 'medium', 'long', or 'full'
+* selector {String}: 'date', 'time', or 'date and time'
+*
+* @return Object.year {Number}: The four digit year
+* Object.month {Number}: The month from (0 - 11)
+* Object.day {Number}: The day from (1 - 31)
+* Object.hour {Number}: The hour from (0 - 23)
+* Object.minute {Number}: The minute from (0 - 59)
+* Object.second {Number}: The second from (0 - 59)
+* Object.millisecond {Number}: The milliseconds (from 0 - 999),
+* not available on all platforms
+*
+* @error GlobalizationError.PARSING_ERROR
+*
+* Example
+* globalization.stringToDate('4/11/2011',
+* function (date) { alert('Month:' + date.month + '\n' +
+* 'Day:' + date.day + '\n' +
+* 'Year:' + date.year + '\n');},
+* function (errorCode) {alert(errorCode);},
+* {selector:'date'});
+*/
+stringToDate:function(dateString, successCB, failureCB, options) {
+ argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "stringToDate", [{"dateString": dateString, "options": options}]);');
+
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.PARSING_ERROR , "unsupported"));
+},
+
+
+/**
+* Returns a pattern string for formatting and parsing dates according to the client's
+* user preferences. It returns the pattern to the successCB callback with a
+* properties object as a parameter. If there is an error obtaining the pattern,
+* then the errorCB callback is invoked.
+*
+* The defaults are: formatLength="short" and selector="date and time"
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* formatLength {String}: 'short', 'medium', 'long', or 'full'
+* selector {String}: 'date', 'time', or 'date and time'
+*
+* @return Object.pattern {String}: The date and time pattern for formatting and parsing dates.
+* The patterns follow Unicode Technical Standard #35
+* http://unicode.org/reports/tr35/tr35-4.html
+* Object.timezone {String}: The abbreviated name of the time zone on the client
+* Object.utc_offset {Number}: The current difference in seconds between the client's
+* time zone and coordinated universal time.
+* Object.dst_offset {Number}: The current daylight saving time offset in seconds
+* between the client's non-daylight saving's time zone
+* and the client's daylight saving's time zone.
+*
+* @error GlobalizationError.PATTERN_ERROR
+*
+* Example
+* globalization.getDatePattern(
+* function (date) {alert('pattern:' + date.pattern + '\n');},
+* function () {},
+* {formatLength:'short'});
+*/
+getDatePattern:function(successCB, failureCB, options) {
+ console.log(' exec(successCB, failureCB, "Globalization", "getDatePattern", [{"options": options}]);');
+
+ var shortFormat = (options) ? ( options.formatLength === 'short') : true;
+
+ var formatString = tizen.time.getDateFormat ( shortFormat);
+
+
+ var current_datetime = tizen.time.getCurrentDateTime();
+
+ // probably will require some control of operation...
+ if (formatString)
+ {
+ successCB(
+ {
+ "pattern": formatString,
+ "timezone": current_datetime.getTimezoneAbbreviation(),
+ "utc_offset": current_datetime.difference(current_datetime.toUTC()).length,
+ "dst_offset": current_datetime.isDST()
+ }
+ );
+ }
+ else {
+ failureCB(new GlobalizationError(GlobalizationError.PATTERN_ERROR , "cannot get pattern"));
+ }
+},
+
+
+/**
+* Returns an array of either the names of the months or days of the week
+* according to the client's user preferences and calendar. It returns the array of names to the
+* successCB callback with a properties object as a parameter. If there is an error obtaining the
+* names, then the errorCB callback is invoked.
+*
+* The defaults are: type="wide" and item="months"
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'narrow' or 'wide'
+* item {String}: 'months', or 'days'
+*
+* @return Object.value {Array{String}}: The array of names starting from either
+* the first month in the year or the
+* first day of the week.
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getDateNames(function (names) {
+* for(var i = 0; i < names.value.length; i++) {
+* alert('Month:' + names.value[i] + '\n');}},
+* function () {});
+*/
+getDateNames:function(successCB, failureCB, options) {
+ argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "getDateNames", [{"options": options}]);');
+
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+},
+
+/**
+* Returns whether daylight savings time is in effect for a given date using the client's
+* time zone and calendar. It returns whether or not daylight savings time is in effect
+* to the successCB callback with a properties object as a parameter. If there is an error
+* reading the date, then the errorCB callback is invoked.
+*
+* @param {Date} date
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.dst {Boolean}: The value "true" indicates that daylight savings time is
+* in effect for the given date and "false" indicate that it is not.
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.isDayLightSavingsTime(new Date(),
+* function (date) {alert('dst:' + date.dst + '\n');}
+* function () {});
+*/
+isDayLightSavingsTime:function(date, successCB, failureCB) {
+
+ var tzdate = null,
+ isDLS = false;
+
+ console.log('exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", [{"date": dateValue}]);');
+ console.log("date " + date + " value " + date.valueOf()) ;
+
+ tzdate = new tizen.TZDate(date);
+ if (tzdate) {
+ isDLS = false | (tzdate && tzdate.isDST());
+
+ console.log ("Cordova, globalization, isDayLightSavingsTime, " + isDLS);
+
+ successCB({"dst":isDLS});
+ }
+ else {
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "cannot get information"));
+ }
+},
+
+/**
+* Returns the first day of the week according to the client's user preferences and calendar.
+* The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
+* It returns the day to the successCB callback with a properties object as a parameter.
+* If there is an error obtaining the pattern, then the errorCB callback is invoked.
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.value {Number}: The number of the first day of the week.
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getFirstDayOfWeek(function (day)
+* { alert('Day:' + day.value + '\n');},
+* function () {});
+*/
+getFirstDayOfWeek:function(successCB, failureCB) {
+ argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "getFirstDayOfWeek", []);');
+
+ // there is no API to get the fist day of the week in Tizen Dvice API
+ successCB({value:1});
+
+ // first day of week is a settings in the date book app
+ // what about : getting the settings directly or asking the date book ?
+},
+
+
+/**
+* Returns a number formatted as a string according to the client's user preferences.
+* It returns the formatted number string to the successCB callback with a properties object as a
+* parameter. If there is an error formatting the number, then the errorCB callback is invoked.
+*
+* The defaults are: type="decimal"
+*
+* @param {Number} number
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'decimal', "percent", or 'currency'
+*
+* @return Object.value {String}: The formatted number string.
+*
+* @error GlobalizationError.FORMATTING_ERROR
+*
+* Example
+* globalization.numberToString(3.25,
+* function (number) {alert('number:' + number.value + '\n');},
+* function () {},
+* {type:'decimal'});
+*/
+numberToString:function(number, successCB, failureCB, options) {
+ argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "numberToString", [{"number": number, "options": options}]);');
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+},
+
+/**
+* Parses a number formatted as a string according to the client's user preferences and
+* returns the corresponding number. It returns the number to the successCB callback with a
+* properties object as a parameter. If there is an error parsing the number string, then
+* the errorCB callback is invoked.
+*
+* The defaults are: type="decimal"
+*
+* @param {String} numberString
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'decimal', "percent", or 'currency'
+*
+* @return Object.value {Number}: The parsed number.
+*
+* @error GlobalizationError.PARSING_ERROR
+*
+* Example
+* globalization.stringToNumber('1234.56',
+* function (number) {alert('Number:' + number.value + '\n');},
+* function () { alert('Error parsing number');});
+*/
+stringToNumber:function(numberString, successCB, failureCB, options) {
+ argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "stringToNumber", [{"numberString": numberString, "options": options}]);');
+
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+},
+
+/**
+* Returns a pattern string for formatting and parsing numbers according to the client's user
+* preferences. It returns the pattern to the successCB callback with a properties object as a
+* parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
+*
+* The defaults are: type="decimal"
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'decimal', "percent", or 'currency'
+*
+* @return Object.pattern {String}: The number pattern for formatting and parsing numbers.
+* The patterns follow Unicode Technical Standard #35.
+* http://unicode.org/reports/tr35/tr35-4.html
+* Object.symbol {String}: The symbol to be used when formatting and parsing
+* e.g., percent or currency symbol.
+* Object.fraction {Number}: The number of fractional digits to use when parsing and
+* formatting numbers.
+* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
+* Object.positive {String}: The symbol to use for positive numbers when parsing and formatting.
+* Object.negative: {String}: The symbol to use for negative numbers when parsing and formatting.
+* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
+* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
+*
+* @error GlobalizationError.PATTERN_ERROR
+*
+* Example
+* globalization.getNumberPattern(
+* function (pattern) {alert('Pattern:' + pattern.pattern + '\n');},
+* function () {});
+*/
+getNumberPattern:function(successCB, failureCB, options) {
+ argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "getNumberPattern", [{"options": options}]);');
+
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+},
+
+/**
+* Returns a pattern string for formatting and parsing currency values according to the client's
+* user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
+* properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
+* callback is invoked.
+*
+* @param {String} currencyCode
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.pattern {String}: The currency pattern for formatting and parsing currency values.
+* The patterns follow Unicode Technical Standard #35
+* http://unicode.org/reports/tr35/tr35-4.html
+* Object.code {String}: The ISO 4217 currency code for the pattern.
+* Object.fraction {Number}: The number of fractional digits to use when parsing and
+* formatting currency.
+* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
+* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
+* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
+*
+* @error GlobalizationError.FORMATTING_ERROR
+*
+* Example
+* globalization.getCurrencyPattern('EUR',
+* function (currency) {alert('Pattern:' + currency.pattern + '\n');}
+* function () {});
+*/
+getCurrencyPattern:function(currencyCode, successCB, failureCB) {
+ argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "getCurrencyPattern", [{"currencyCode": currencyCode}]);');
+
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+}
+
+};
+
+module.exports = globalization;
diff --git a/lib/tizen/plugin/tizen/SplashScreen.js b/lib/tizen/plugin/tizen/SplashScreen.js
new file mode 100644
index 0000000..1187c45
--- /dev/null
+++ b/lib/tizen/plugin/tizen/SplashScreen.js
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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('cordova/exec');
+
+var splashscreen = {
+
+ window: null,
+
+
+ show:function() {
+ console.log ("tizen splashscreen show()");
+
+ // open a windows in splashscreen.window
+ // add DOM with an Image
+
+ },
+ hide:function() {
+ console.log ("tizen splashscreen hide()");
+ //delete the window splashscreen.window
+ //set to null
+ }
+};
+
+module.exports = splashscreen;
diff --git a/lib/windows8/plugin/windows8/DeviceProxy.js b/lib/windows8/plugin/windows8/DeviceProxy.js
index cf442e3..7379f48 100644
--- a/lib/windows8/plugin/windows8/DeviceProxy.js
+++ b/lib/windows8/plugin/windows8/DeviceProxy.js
@@ -27,16 +27,6 @@
module.exports = {
getDeviceInfo:function(win,fail,args) {
- //console.log("NativeProxy::getDeviceInfo");
- var hostNames = Windows.Networking.Connectivity.NetworkInformation.getHostNames();
-
- var name = "unknown";
- hostNames.some(function (nm) {
- if (nm.displayName.indexOf(".local") > -1) {
- name = nm.displayName.split(".local")[0];
- return true;
- }
- });
// deviceId aka uuid, stored in Windows.Storage.ApplicationData.current.localSettings.values.deviceId
var deviceId;
@@ -50,7 +40,7 @@
}
setTimeout(function () {
- win({ platform: "windows8", version: "8", name: name, uuid: deviceId, cordova: CORDOVA_JS_BUILD_LABEL });
+ win({ platform: "windows8", version: "8", uuid: deviceId, cordova: CORDOVA_JS_BUILD_LABEL });
}, 0);
}
diff --git a/lib/windowsphone/plugin/windowsphone/DOMStorage/plugininit.js b/lib/windowsphone/plugin/windowsphone/DOMStorage/plugininit.js
deleted file mode 100644
index c546c0f..0000000
--- a/lib/windowsphone/plugin/windowsphone/DOMStorage/plugininit.js
+++ /dev/null
@@ -1,200 +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.
- *
-*/
-
-(function(win,doc) {
-
-var docDomain = null;
-try {
- docDomain = doc.domain;
-} catch (err) {
- //console.log("caught exception trying to access document.domain");
-}
-
-// conditionally patch the window.localStorage and window.sessionStorage objects
-if (!docDomain || docDomain.length === 0) {
-
- var DOMStorage = function(type) {
- // default type is local
- if(type == "sessionStorage") {
- this._type = type;
- }
- Object.defineProperty( this, "length", {
- configurable: true,
- get: function(){ return this.getLength(); }
- });
- };
-
- DOMStorage.prototype = {
- _type:"localStorage",
- _result:null,
- keys:null,
-
- onResult:function(key,valueStr) {
- if(!this.keys) {
- this.keys = [];
- }
- this._result = valueStr;
- },
-
- onKeysChanged:function(jsonKeys) {
- this.keys = JSON.parse(jsonKeys);
-
- var key;
- for(var n = 0,len = this.keys.length; n < len; n++) {
- key = this.keys[n];
- if(!this.hasOwnProperty(key)) {
- Object.defineProperty( this, key, {
- configurable: true,
- get: function(){ return this.getItem(key); },
- set: function(val){ return this.setItem(key,val); }
- });
- }
- }
-
- },
-
- initialize:function() {
- window.external.Notify("DOMStorage/" + this._type + "/load/keys");
- },
-
- /*
- The length attribute must return the number of key/value pairs currently present
- in the list associated with the object.
- */
- getLength:function() {
- if(!this.keys) {
- this.initialize();
- }
- return this.keys.length;
- },
-
- /*
- The key(n) method must return the name of the nth key in the list.
- The order of keys is user-agent defined, but must be consistent within an object so long as the number of keys doesn't change.
- (Thus, adding or removing a key may change the order of the keys, but merely changing the value of an existing key must not.)
- If n is greater than or equal to the number of key/value pairs in the object, then this method must return null.
- */
- key:function(n) {
- if(!this.keys) {
- this.initialize();
- }
-
- if(n >= this.keys.length) {
- return null;
- } else {
- return this.keys[n];
- }
- },
-
- /*
- The getItem(key) method must return the current value associated with the given key.
- If the given key does not exist in the list associated with the object then this method must return null.
- */
- getItem:function(key) {
- if(!this.keys) {
- this.initialize();
- }
-
- var retVal = null;
- if(this.keys.indexOf(key) > -1) {
- window.external.Notify("DOMStorage/" + this._type + "/get/" + key);
- retVal = window.unescape(decodeURIComponent(this._result));
- this._result = null;
- }
- return retVal;
- },
- /*
- The setItem(key, value) method must first check if a key/value pair with the given key already exists
- in the list associated with the object.
- If it does not, then a new key/value pair must be added to the list, with the given key and with its value set to value.
- If the given key does exist in the list, then it must have its value updated to value.
- If it couldn't set the new value, the method must raise an QUOTA_EXCEEDED_ERR exception.
- (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)
- */
- setItem:function(key,value) {
- if(!this.keys) {
- this.initialize();
- }
- window.external.Notify("DOMStorage/" + this._type + "/set/" + key + "/" + encodeURIComponent(window.escape(value)));
- },
-
- /*
- The removeItem(key) method must cause the key/value pair with the given key to be removed from the list
- associated with the object, if it exists.
- If no item with that key exists, the method must do nothing.
- */
- removeItem:function(key) {
- if(!this.keys) {
- this.initialize();
- }
- var index = this.keys.indexOf(key);
- if(index > -1) {
- this.keys.splice(index,1);
- // TODO: need sanity check for keys ? like 'clear','setItem', ...
- window.external.Notify("DOMStorage/" + this._type + "/remove/" + key);
- delete this[key];
- }
- },
-
- /*
- The clear() method must atomically cause the list associated with the object to be emptied of all
- key/value pairs, if there are any.
- If there are none, then the method must do nothing.
- */
- clear:function() {
- if(!this.keys) {
- this.initialize();
- }
-
- for(var n=0,len=this.keys.length; n < len;n++) {
- // TODO: do we need a sanity check for keys ? like 'clear','setItem', ...
- delete this[this.keys[n]];
- }
- this.keys = [];
- window.external.Notify("DOMStorage/" + this._type + "/clear/");
- }
- };
-
- // initialize DOMStorage
-
- if (typeof window.localStorage === "undefined") {
-
- Object.defineProperty(window, "localStorage", {
- writable: false,
- configurable: false,
- value: new DOMStorage("localStorage")
- });
- window.localStorage.initialize();
- }
-
- if (typeof window.sessionStorage === "undefined") {
- Object.defineProperty(window, "sessionStorage", {
- writable: false,
- configurable: false,
- value: new DOMStorage("sessionStorage")
- });
- window.sessionStorage.initialize();
- }
-}
-
-})(window, document);
-
-module.exports = null;
diff --git a/lib/windowsphone/plugin/windowsphone/XHRPatch/plugininit.js b/lib/windowsphone/plugin/windowsphone/XHRPatch/plugininit.js
deleted file mode 100644
index 27fd21d..0000000
--- a/lib/windowsphone/plugin/windowsphone/XHRPatch/plugininit.js
+++ /dev/null
@@ -1,255 +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.
- *
-*/
-
-// TODO: the build process will implicitly wrap this in a define() call
-// with a closure of its own; do you need this extra closure?
-
-var LocalFileSystem = require('cordova/plugin/LocalFileSystem');
-
-(function (win, doc) {
-
-var docDomain = null;
-try {
- docDomain = doc.domain;
-} catch (err) {
- //console.log("caught exception trying to access document.domain");
-}
-
-if (!docDomain || docDomain.length === 0) {
-
- var aliasXHR = win.XMLHttpRequest;
-
- win.XMLHttpRequest = function () { };
- win.XMLHttpRequest.noConflict = aliasXHR;
- win.XMLHttpRequest.UNSENT = 0;
- win.XMLHttpRequest.OPENED = 1;
- win.XMLHttpRequest.HEADERS_RECEIVED = 2;
- win.XMLHttpRequest.LOADING = 3;
- win.XMLHttpRequest.DONE = 4;
-
- win.XMLHttpRequest.prototype = {
- UNSENT: 0,
- OPENED: 1,
- HEADERS_RECEIVED: 2,
- LOADING: 3,
- DONE: 4,
-
- isAsync: false,
- onreadystatechange: null,
- readyState: 0,
- _url: "",
- timeout: 0,
- withCredentials: false,
- _requestHeaders: null,
- open: function (reqType, uri, isAsync, user, password) {
-
- if (uri && uri.indexOf("http") === 0) {
- if (!this.wrappedXHR) {
- this.wrappedXHR = new aliasXHR();
- var self = this;
-
- // timeout
- if (this.timeout > 0) {
- this.wrappedXHR.timeout = this.timeout;
- }
- Object.defineProperty(this, "timeout", {
- set: function (val) {
- this.wrappedXHR.timeout = val;
- },
- get: function () {
- return this.wrappedXHR.timeout;
- }
- });
-
-
-
- if (this.withCredentials) {
- this.wrappedXHR.withCredentials = this.withCredentials;
- }
- Object.defineProperty(this, "withCredentials", {
- set: function (val) {
- this.wrappedXHR.withCredentials = val;
- },
- get: function () {
- return this.wrappedXHR.withCredentials;
- }
- });
-
-
- Object.defineProperty(this, "status", { get: function () {
- return this.wrappedXHR.status;
- }
- });
- Object.defineProperty(this, "responseText", { get: function () {
- return this.wrappedXHR.responseText;
- }
- });
- Object.defineProperty(this, "statusText", { get: function () {
- return this.wrappedXHR.statusText;
- }
- });
-
- Object.defineProperty(this, "responseXML", { get: function () {
- return this.wrappedXHR.responseXML;
- }
- });
-
- this.getResponseHeader = function (header) {
- return this.wrappedXHR.getResponseHeader(header);
- };
- this.getAllResponseHeaders = function () {
- return this.wrappedXHR.getAllResponseHeaders();
- };
-
- this.wrappedXHR.onreadystatechange = function () {
- self.changeReadyState(self.wrappedXHR.readyState);
- };
- }
- return this.wrappedXHR.open(reqType, uri, isAsync, user, password);
- }
- else {
- // x-wmapp1://app/www/page2.html
- // need to work some magic on the actual url/filepath
- var newUrl = uri;
- if (newUrl.indexOf(":/") > -1) {
- newUrl = newUrl.split(":/")[1];
- }
- // prefix relative urls to our physical root
- if(newUrl.indexOf("app/www/") < 0 && this.getContentLocation() == this.contentLocation.ISOLATED_STORAGE)
- {
- newUrl = "app/www/" + newUrl;
- }
-
- if (newUrl.lastIndexOf("/") === newUrl.length - 1) {
- newUrl += "index.html"; // default page is index.html, when call is to a dir/ ( why not ...? )
- }
- this._url = newUrl;
- }
- },
- statusText: "",
- changeReadyState: function (newState) {
- this.readyState = newState;
- if (this.onreadystatechange) {
- this.onreadystatechange();
- }
- },
- setRequestHeader: function (header, value) {
- if (this.wrappedXHR) {
- this.wrappedXHR.setRequestHeader(header, value);
- }
- },
- getResponseHeader: function (header) {
- return this.wrappedXHR ? this.wrappedXHR.getResponseHeader(header) : "";
- },
- getAllResponseHeaders: function () {
- return this.wrappedXHR ? this.wrappedXHR.getAllResponseHeaders() : "";
- },
- responseText: "",
- responseXML: "",
- onResult: function (res) {
- this.status = 200;
- if(typeof res == "object")
- { // callback result handler may have already parsed this from a string-> a JSON object,
- // if so, we need to restore its stringyness, as handlers are expecting string data.
- // especially if used with jQ -> $.getJSON
- res = JSON.stringify(res);
- }
- this.responseText = res;
- this.responseXML = res;
- this.changeReadyState(this.DONE);
- },
- onError: function (err) {
- this.status = 404;
- this.changeReadyState(this.DONE);
- },
-
- abort: function () {
- if (this.wrappedXHR) {
- return this.wrappedXHR.abort();
- }
- },
-
- send: function (data) {
- if (this.wrappedXHR) {
- return this.wrappedXHR.send(data);
- }
- else {
- this.changeReadyState(this.OPENED);
-
- var alias = this;
-
- var fail = function fail(evt) {
- alias.onError(evt.code);
- };
-
- if (alias.getContentLocation() == this.contentLocation.RESOURCES) {
- var exec = require('cordova/exec');
- exec(function(result) {
- alias.onResult.apply(alias, [result]);
- },
- fail,
- "File", "readResourceAsText", [alias._url]
- );
- }
- else {
- var gotFile = function gotFile(file) {
- var reader = new FileReader();
- reader.onloadend = function (evt) {
- alias.onResult.apply(alias,[evt.target.result]);
- };
- reader.readAsText(file);
- };
-
- var gotEntry = function gotEntry(entry) {
- entry.file(gotFile, fail);
- };
-
- var gotFS = function gotFS(fs) {
- fs.root.getFile(alias._url, null, gotEntry, fail);
- };
-
- window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
- }
- }
- },
-
- getContentLocation: function () {
- if (window.contentLocation === undefined) {
- window.contentLocation = (navigator.userAgent.toUpperCase().indexOf('MSIE 10') > -1) ?
- this.contentLocation.RESOURCES : this.contentLocation.ISOLATED_STORAGE;
- }
-
- return window.contentLocation;
- },
-
- contentLocation:{
- ISOLATED_STORAGE: 0,
- RESOURCES: 1
- },
-
- status: 404
- };
-} // if doc domain
-
-// end closure wrap
-})(window, document);
-
-module.exports = null;
diff --git a/test/blackberry10/test.capture.js b/test/blackberry10/test.capture.js
deleted file mode 100644
index 95b48d4..0000000
--- a/test/blackberry10/test.capture.js
+++ /dev/null
@@ -1,222 +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.
- *
-*/
-
-describe("blackberry10 capture", function () {
- var capture = require('cordova/plugin/blackberry10/capture'),
- cordova = require('cordova');
-
- describe("getSupportedAudioModes", function(){
- it('should return Ok', function(){
- expect(capture.getSupportedAudioModes()).toEqual({
- status: cordova.callbackStatus.OK,
- message: []
- });
- });
- });
-
- describe("getSupportedImageModes", function(){
- it('should return Ok', function(){
- expect(capture.getSupportedImageModes()).toEqual({
- status: cordova.callbackStatus.OK,
- message: []
- });
- });
- });
-
- describe("getSupportedVideoModes", function(){
- it('should return Ok', function(){
- expect(capture.getSupportedVideoModes()).toEqual({
- status: cordova.callbackStatus.OK,
- message: []
- });
- });
- });
-
- function testCapture(method, action) {
- describe(method, function(){
- beforeEach(function () {
- global.blackberry = {
- invoke: {
- card: {
- invokeCamera: jasmine.createSpy('blackberry.invoke.card.invokeCamera')
- }
- }
- };
- });
-
- afterEach(function () {
- delete global.blackberry;
- });
-
- it('should return No Result', function(){
- var args = [{limit: 0}],
- win = jasmine.createSpy('win'),
- fail = jasmine.createSpy('fail');
-
- expect(capture[method](args, win, fail)).toEqual({
- status: cordova.callbackStatus.NO_RESULT,
- message: "WebWorks Is On It"
- });
- });
-
- describe("when the limit is 0 or less", function () {
- it('calls the win callback with an empty array', function(){
- var args = [{ limit: -9 }],
- win = jasmine.createSpy('win'),
- fail = jasmine.createSpy('fail');
-
- capture[method](args, win, fail);
- expect(win).toHaveBeenCalled();
- });
- });
-
- describe("when the limit is greater than 0", function () {
- var win, fail;
-
- beforeEach(function () {
- win = jasmine.createSpy("win");
- fail = jasmine.createSpy("fail");
- });
-
- it("calls the invokeCamera method", function () {
- capture[method]([{limit: 1}], win, fail);
- expect(blackberry.invoke.card.invokeCamera).toHaveBeenCalledWith(action,
- jasmine.any(Function),
- jasmine.any(Function),
- jasmine.any(Function));
- });
-
- describe("inside the invokeCamera callback", function () {
- var onsave;
-
- beforeEach(function () {
- window.webkitRequestFileSystem = jasmine.createSpy("window.webkitRequestFileSystem");
- global.blackberry.io = { sandbox: true };
-
- capture[method]([{limit: 1}], win, fail);
- onsave = blackberry.invoke.card.invokeCamera.mostRecentCall.args[1];
- });
-
- afterEach(function () {
- delete window.webkitRequestFileSystem;
- });
-
- it("sets the sandbox to false", function () {
- onsave();
- expect(blackberry.io.sandbox).toBe(false);
- });
-
- it("calls webkitRequestFileSystem", function () {
- onsave();
- expect(window.webkitRequestFileSystem).toHaveBeenCalledWith(
- window.PERSISTENT,
- 1024,
- jasmine.any(Function),
- fail);
- });
-
- describe("in the webkitRequestFileSystem callback", function () {
- var callback,
- fs = { root: { getFile: jasmine.createSpy("getFile") } };
-
- beforeEach(function () {
- onsave('/foo/bar/baz.gif');
- callback = window.webkitRequestFileSystem.mostRecentCall.args[2];
- });
-
- it("calls getfile on the provided filesystem", function () {
- callback(fs);
- expect(fs.root.getFile).toHaveBeenCalledWith('/foo/bar/baz.gif',
- {},
- jasmine.any(Function),
- fail);
- });
-
- it("calls the file method of the fileEntity", function () {
- var fe = { file: jasmine.createSpy('file') };
- callback(fs);
- fs.root.getFile.mostRecentCall.args[2](fe);
- expect(fe.file).toHaveBeenCalledWith(jasmine.any(Function), fail);
- });
-
- describe("in the file callback", function () {
- var fe = {
- file: jasmine.createSpy('file'),
- fullPath: 'file://this/is/the/full/path/eh.png'
- },
- fileCB;
-
- beforeEach(function () {
- callback(fs);
- fs.root.getFile.mostRecentCall.args[2](fe);
- fileCB = fe.file.mostRecentCall.args[0];
- });
-
- it("sets the fullPath of the file object", function () {
- var file = {};
- fileCB(file);
- expect(file.fullPath).toBe(fe.fullPath);
- });
-
- it("calls the win callback with an array containing the file", function () {
- var file = {};
- fileCB(file);
- expect(win).toHaveBeenCalledWith([file]);
- });
-
- it("resets the value of blackberry.io.sandbox", function () {
- var file = {};
- fileCB(file);
- expect(blackberry.io.sandbox).toBe(true);
- });
- });
- });
- });
- });
- });
- }
-
- testCapture('captureImage', 'photo');
- testCapture('captureVideo', 'video');
-
- describe("captureAudio", function(){
- it('should call the fail callback', function(){
- var args = {},
- win = jasmine.createSpy('win'),
- fail = jasmine.createSpy('fail');
-
- capture.captureAudio(args, win, fail);
- expect(fail).toHaveBeenCalled();
- expect(win).not.toHaveBeenCalled();
- });
-
- it('should return no result', function(){
- var args = "arguments",
- win = jasmine.createSpy('win'),
- fail = jasmine.createSpy('fail');
-
- expect(capture.captureAudio(args, win, fail)).toEqual({
- status: cordova.callbackStatus.NO_RESULT,
- message: "WebWorks Is On It"
- });
- });
- });
-});
diff --git a/test/runner.js b/test/runner.js
index 51846ba..97b713a 100644
--- a/test/runner.js
+++ b/test/runner.js
@@ -53,7 +53,7 @@
window = document.createWindow();
} catch (e) {
//no jsDom (some people don't have compilers)
- throw new Error("can't run tests in node: run jake btest instead, or install jsdom via: npm install");
+ throw new Error("can't run tests in node: run grunt btest instead, or install jsdom via: npm install");
}
//Put jasmine in scope