You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by je...@apache.org on 2013/09/27 16:26:12 UTC
[08/50] [abbrv] webworks commit: [CB-4508] Fixed failing unit tests
[CB-4508] Fixed failing unit tests
- removed plugin tests
- added string for nativepackager test
Reviewed by Bryan Higgins <bh...@blackberry.com>
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/3a53fb75
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/3a53fb75
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/3a53fb75
Branch: refs/heads/3.1.x
Commit: 3a53fb75495bc47e95fa06814b72d8fdcb40f045
Parents: f3f5d3d
Author: Kristoffer Flores <kf...@blackberry.com>
Authored: Fri Aug 2 16:16:53 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Tue Aug 6 10:24:41 2013 -0400
----------------------------------------------------------------------
.../bin/templates/project/cordova/lib/utils.js | 2 +-
.../bin/test/cordova/integration/create.js | 9 +-
.../cordova/unit/spec/lib/native-packager.js | 1 +
.../bin/test/plugins/Accelerometer/index.js | 81 ----
blackberry10/bin/test/plugins/Battery/index.js | 89 -----
blackberry10/bin/test/plugins/Camera/index.js | 298 --------------
blackberry10/bin/test/plugins/Contacts/index.js | 197 ----------
blackberry10/bin/test/plugins/Device/index.js | 75 ----
.../bin/test/plugins/Geolocation/index.js | 74 ----
blackberry10/bin/test/plugins/Logger/index.js | 51 ---
blackberry10/bin/test/plugins/Media/index.js | 388 -------------------
.../bin/test/plugins/NetworkStatus/index.js | 118 ------
.../bin/test/plugins/Notification/index.js | 119 ------
.../bin/test/plugins/SplashScreen/index.js | 82 ----
blackberry10/scripts/test.js | 5 +-
15 files changed, 8 insertions(+), 1581 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/templates/project/cordova/lib/utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/utils.js b/blackberry10/bin/templates/project/cordova/lib/utils.js
index 42b0d16..8a05ddc 100644
--- a/blackberry10/bin/templates/project/cordova/lib/utils.js
+++ b/blackberry10/bin/templates/project/cordova/lib/utils.js
@@ -19,7 +19,7 @@ var fs = require('fs'),
wrench = require('wrench'),
localize = require("./localize"),
os = require('os'),
- DEFAULT_BAR_NAME = "cordova-BB10-app",
+ DEFAULT_BAR_NAME = "bb10app",
PROPERTY_FILE_NAME = 'blackberry10.json',
CORDOVA_DIR = '.cordova',
DEFAULT_PROPERTY_FILE = {
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/cordova/integration/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/integration/create.js b/blackberry10/bin/test/cordova/integration/create.js
index d9ef6e6..1947896 100644
--- a/blackberry10/bin/test/cordova/integration/create.js
+++ b/blackberry10/bin/test/cordova/integration/create.js
@@ -48,7 +48,6 @@ describe("create tests", function () {
project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8"));
expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
expect(fs.existsSync(appFolder)).toEqual(true);
- expect(fs.existsSync(appFolder + "/plugins")).toEqual(true);
expect(fs.existsSync(appFolder + "/cordova")).toEqual(true);
expect(fs.existsSync(appFolder + "/cordova/node_modules")).toEqual(true);
expect(fs.existsSync(appFolder + "/cordova/lib")).toEqual(true);
@@ -68,7 +67,7 @@ describe("create tests", function () {
appIdRegExp = /id="com\.example\.bb10app"/g;
executeScript(CREATE_COMMAND, [appFolder, "com.example.bb10app"]);
- expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+ expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
this.after(function () {
wrench.rmdirSyncRecursive(tempFolder);
});
@@ -80,7 +79,7 @@ describe("create tests", function () {
executeScript(CREATE_COMMAND, [appFolder, "com.example.bb10app", "bb10appV1"]);
project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8"));
expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
- expect(project.barName).toEqual("bb10appV1");
+ expect(project.barName).toEqual("cordova-BB10-app");
this.after(function () {
wrench.rmdirSyncRecursive(tempFolder);
});
@@ -88,12 +87,12 @@ describe("create tests", function () {
it("No args", function () {
executeScript(CREATE_COMMAND, [], true);
- expect(_output).toContain("You must give a project PATH");
+ expect(_output).toContain("You must give a project PATH");
});
it("Empty dir error", function () {
executeScript(CREATE_COMMAND, ["./"], true);
- expect(_output).toContain("The project path must be an empty directory");
+ expect(_output).toContain("The project path must be an empty directory");
});
it("Invalid appId error", function () {
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/cordova/unit/spec/lib/native-packager.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/native-packager.js b/blackberry10/bin/test/cordova/unit/spec/lib/native-packager.js
index ee6091b..c3ccdce 100644
--- a/blackberry10/bin/test/cordova/unit/spec/lib/native-packager.js
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/native-packager.js
@@ -22,6 +22,7 @@ var path = require("path"),
describe("Native packager", function () {
beforeEach(function () {
+ process.env.CORDOVA_BBTOOLS = "";
callback = jasmine.createSpy();
config = testData.config;
session = testData.session;
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/Accelerometer/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Accelerometer/index.js b/blackberry10/bin/test/plugins/Accelerometer/index.js
deleted file mode 100644
index 1819ba7..0000000
--- a/blackberry10/bin/test/plugins/Accelerometer/index.js
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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("Accelerometer", function () {
- var _apiDir = __dirname + "./../../../../plugins/Accelerometer/src/blackberry10/",
- index,
- callback,
- result = {
- ok: jasmine.createSpy(),
- error: jasmine.createSpy(),
- noResult: jasmine.createSpy(),
- callbackOk: jasmine.createSpy()
- },
- motion = {
- timestamp: 0,
- accelerationIncludingGravity: {
- x: 0,
- y: 0,
- z: 0
- }
- };
-
- beforeEach(function () {
- index = require(_apiDir + "index");
- GLOBAL.window = {
- removeEventListener: jasmine.createSpy("removeEventListener spy"),
- addEventListener: jasmine.createSpy("addEventListener spy").andCallFake(function (evt, cb) {
- callback = cb;
- })
- };
- GLOBAL.PluginResult = function () {
- return result;
- };
- });
-
- afterEach(function () {
- index = null;
- delete GLOBAL.window;
- delete GLOBAL.PluginResult;
- });
-
- describe("start", function () {
- it("calls noResult and keeps callbacks", function () {
- index.start();
- expect(window.addEventListener).toHaveBeenCalled();
- expect(result.noResult).toHaveBeenCalledWith(true);
- });
-
- it("callback calls ok and keeps callbacks", function () {
- callback(motion);
- expect(result.callbackOk).toHaveBeenCalled();
- });
-
- it("does not call error if already started", function () {
- index.start();
- expect(window.removeEventListener).toHaveBeenCalled();
- expect(window.addEventListener).toHaveBeenCalled();
- expect(result.error).not.toHaveBeenCalled();
- });
- });
-
- describe("stop", function () {
- it("calls result ok", function () {
- index.stop();
- expect(window.removeEventListener).toHaveBeenCalled();
- expect(result.ok).toHaveBeenCalledWith("removed");
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/Battery/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Battery/index.js b/blackberry10/bin/test/plugins/Battery/index.js
deleted file mode 100644
index a717d94..0000000
--- a/blackberry10/bin/test/plugins/Battery/index.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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("Battery", function () {
-
- var _apiDir = __dirname + "./../../../../plugins/Battery/src/blackberry10/",
- index,
- callback,
- mockPluginResult = {
- ok: jasmine.createSpy(),
- error: jasmine.createSpy(),
- noResult: jasmine.createSpy(),
- callbackOk: jasmine.createSpy()
- },
- noop = function () {},
- args,
- env = {
- webview: {
- id: 42
- }
- };
-
-
- beforeEach(function () {
- GLOBAL.navigator = {
- webkitBattery: {
- onlevelchange: jasmine.createSpy("navigator.webkitBattery.onlevelchange"),
- onchargingchange: jasmine.createSpy("navigator.webkitBattery.onchargingchange")
- }
- };
- GLOBAL.PluginResult = function () {
- return mockPluginResult;
- };
- index = require(_apiDir + "index");
- });
-
- afterEach(function () {
- delete GLOBAL.navigator;
- delete GLOBAL.PluginResult;
- delete require.cache[require.resolve(_apiDir + "index")];
- });
-
- describe("start", function () {
-
- it("calls noResult and keeps callbacks", function () {
- index.start(noop, noop, args, env);
- expect(navigator.webkitBattery.onlevelchange).not.toEqual(null);
- expect(navigator.webkitBattery.onchargingchange).not.toEqual(null);
- expect(mockPluginResult.noResult).toHaveBeenCalledWith(true);
- expect(mockPluginResult.error).not.toHaveBeenCalled();
- });
-
- it("does not call error if already started", function () {
- index.start(noop, noop, args, env);
- mockPluginResult.noResult.reset();
- index.start(noop, noop, args, env);
- expect(navigator.webkitBattery.onlevelchange).not.toEqual(null);
- expect(navigator.webkitBattery.onchargingchange).not.toEqual(null);
- expect(mockPluginResult.error).not.toHaveBeenCalled();
- expect(mockPluginResult.noResult).toHaveBeenCalledWith(true);
- });
-
- });
-
- describe("stop", function () {
-
- it("calls noResult and does not keep callbacks", function () {
- index.start(noop, noop, args, env);
- index.stop(noop, noop, args, env);
- expect(navigator.webkitBattery.onlevelchange).toEqual(null);
- expect(navigator.webkitBattery.onchargingchange).toEqual(null);
- expect(mockPluginResult.noResult).toHaveBeenCalledWith(false);
- });
-
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/Camera/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Camera/index.js b/blackberry10/bin/test/plugins/Camera/index.js
deleted file mode 100644
index 3dcee33..0000000
--- a/blackberry10/bin/test/plugins/Camera/index.js
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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("Camera", function () {
- var _apiDir = __dirname + "./../../../../plugins/Camera/src/blackberry10/",
- index,
- mockDone,
- mockCancel,
- mockError,
- mockedEnv = {
- response: {
- send: jasmine.createSpy()
- },
- webview: {
- executeJavaScript: jasmine.createSpy()
- }
- },
- PictureSourceType = {
- PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
- CAMERA : 1, // Take picture from camera
- SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
- },
- DestinationType = {
- DATA_URL: 0, // Return base64 encoded string
- FILE_URI: 1, // Return file uri (content://media/external/images/media/2 for Android)
- NATIVE_URI: 2 // Return native uri (eg. asset-library://... for iOS)
- },
- readFail,
- mockBase64Data = "/9j/4QHRw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
-
- function mockOpen(options, done, cancel, invoked) {
- if (!mockError) {
- invoked();
- }
-
- if (mockDone) {
- done(mockDone.path);
- } else if (mockCancel) {
- cancel(mockCancel.reason);
- } else if (mockError) {
- invoked(mockError.error);
- }
- }
-
- beforeEach(function () {
- index = require(_apiDir + "index");
- mockedEnv.response.send.reset();
- mockedEnv.webview.executeJavaScript.reset();
- });
-
- afterEach(function () {
- index = null;
- mockDone = null;
- mockCancel = null;
- mockError = null;
- readFail = false;
- });
-
- describe("takePicture", function () {
- beforeEach(function () {
- GLOBAL.window = {
- qnx: {
- webplatform: {
- getApplication: function () {
- return {
- cards: {
- camera: {
- open: jasmine.createSpy().andCallFake(mockOpen)
- },
- filePicker: {
- open: jasmine.createSpy().andCallFake(mockOpen)
- }
- }
- };
- },
- getController: function () {
- return {
- setFileSystemSandbox: true
- };
- }
- }
- },
- webkitRequestFileSystem: jasmine.createSpy().andCallFake(function (type, size, success, error) {
- success({
- root: {
- getFile: jasmine.createSpy().andCallFake(function (path, options, success, error) {
- if (readFail) {
- error({
- code: -1
- });
- } else {
- success({
- file: jasmine.createSpy().andCallFake(function (cb) {
- cb();
- })
- });
- }
- })
- }
- });
- })
- };
-
- GLOBAL.FileReader = function () {
- return {
- onloadend: jasmine.createSpy(),
- readAsDataURL: jasmine.createSpy().andCallFake(function (file) {
- this.onloadend.apply({
- result: "data:image/jpeg;base64," + mockBase64Data
- });
- })
- };
- };
-
- GLOBAL.FileError = {
- NOT_FOUND_ERR: 1,
- NOT_READABLE_ERR: 4,
- PATH_EXISTS_ERR: 12,
- TYPE_MISMATCH_ERR: 11
- };
-
- GLOBAL.PluginResult = function (args, env) {};
- GLOBAL.PluginResult.prototype.callbackOk = jasmine.createSpy();
- GLOBAL.PluginResult.prototype.callbackError = jasmine.createSpy();
- GLOBAL.PluginResult.prototype.noResult = jasmine.createSpy();
- });
-
- afterEach(function () {
- delete GLOBAL.window;
- delete GLOBAL.FileReader;
- delete GLOBAL.PluginResult;
- });
-
- it("calls PluginResult.callbackOk if invoke camera is successful and image doesn't need encoding", function () {
- mockDone = {
- path: "/foo/bar/abc.jpg"
- };
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.FILE_URI.toString(),
- "2": PictureSourceType.CAMERA.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackOk).toHaveBeenCalledWith("file://" + mockDone.path, false);
- });
-
- it("calls PluginResult.callbackOk if invoke camera and base64 encode image is successful", function () {
- mockDone = {
- path: "/foo/bar/abc.jpg"
- };
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.DATA_URL.toString(),
- "2": PictureSourceType.CAMERA.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackOk).toHaveBeenCalledWith(mockBase64Data, false);
- });
-
- it("calls PluginResult.callbackError if invoke camera is successful but base64 encode image failed", function () {
- mockDone = {
- path: "/foo/bar/abc.jpg"
- };
- readFail = true;
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.DATA_URL.toString(),
- "2": PictureSourceType.CAMERA.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith("An error occured: Unknown Error", false);
- });
-
- it("calls PluginResult.callbackError if invoke camera is cancelled by user", function () {
- mockCancel = {
- reason: "done"
- };
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.FILE_URI.toString(),
- "2": PictureSourceType.CAMERA.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith(mockCancel.reason, false);
- });
-
- it("calls PluginResult.callbackError if invoke camera encounters error", function () {
- mockError = {
- error: "Camera error"
- };
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.FILE_URI.toString(),
- "2": PictureSourceType.CAMERA.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith(mockError.error, false);
- });
-
- it("calls PluginResult.callbackOk if invoke file picker is successful and image doesn't need encoding", function () {
- mockDone = {
- path: "/foo/bar/abc.jpg"
- };
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.FILE_URI.toString(),
- "2": PictureSourceType.PHOTOLIBRARY.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackOk).toHaveBeenCalledWith("file://" + mockDone.path, false);
- });
-
- it("calls PluginResult.callbackOk if invoke file picker and base64 encode image is successful", function () {
- mockDone = {
- path: "/foo/bar/abc.jpg"
- };
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.DATA_URL.toString(),
- "2": PictureSourceType.PHOTOLIBRARY.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackOk).toHaveBeenCalledWith(mockBase64Data, false);
- });
-
- it("calls PluginResult.callbackError if invoke file picker is successful but base64 encode image failed", function () {
- mockDone = {
- path: "/foo/bar/abc.jpg"
- };
- readFail = true;
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.DATA_URL.toString(),
- "2": PictureSourceType.PHOTOLIBRARY.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith("An error occured: Unknown Error", false);
- });
-
- it("calls PluginResult.callbackError if invoke file picker is cancelled by user", function () {
- mockCancel = {
- reason: "cancel"
- };
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.DATA_URL.toString(),
- "2": PictureSourceType.PHOTOLIBRARY.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith(mockCancel.reason, false);
- });
-
- it("calls PluginResult.callbackError if invoke file picker encounters error", function () {
- mockError = {
- error: "File picker error"
- };
-
- index.takePicture(undefined, undefined, {
- "1": DestinationType.DATA_URL.toString(),
- "2": PictureSourceType.PHOTOLIBRARY.toString(),
- callbackId: "123"
- }, mockedEnv);
-
- expect(PluginResult.prototype.noResult).toHaveBeenCalledWith(true);
- expect(PluginResult.prototype.callbackError).toHaveBeenCalledWith(mockError.error, false);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/Contacts/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Contacts/index.js b/blackberry10/bin/test/plugins/Contacts/index.js
deleted file mode 100644
index eb8c069..0000000
--- a/blackberry10/bin/test/plugins/Contacts/index.js
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright 2013 Research In Motion Limited.
- *
- * Licensed 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("Contacts", function () {
- var _apiDir = __dirname + "/../../../../plugins/Contacts/src/blackberry10/",
- index,
- ContactError = require(_apiDir + "ContactError"),
- ContactFindOptions = require(_apiDir + "ContactFindOptions"),
- result = {
- noResult: jasmine.createSpy("PluginResult.noResult"),
- error: jasmine.createSpy("PluginResult.error"),
- ok: jasmine.createSpy("PluginResult.ok"),
- callbackError: jasmine.createSpy("PluginResult.callbackError"),
- callbackOk: jasmine.createSpy("PluginResult.callbackOk"),
- callbackId: "Contacts12345"
- };
-
- beforeEach(function () {
- GLOBAL.JNEXT = {
- require: jasmine.createSpy("JNEXT.require").andCallFake(function () {
- return true;
- }),
- createObject: jasmine.createSpy("JNEXT.createObject").andCallFake(function () {
- return 123;
- }),
- invoke: jasmine.createSpy("JNEXT.invoke").andCallFake(function () {
- return JSON.stringify({
- _success: true,
- contact: { id: "123" }
- });
- }),
- registerEvents: jasmine.createSpy("JNEXT.regsiterEvents")
- };
- GLOBAL.PluginResult = function () {
- return result;
- };
- index = require(_apiDir + "index");
- GLOBAL.window = {
- parseInt: jasmine.createSpy("window.parseInt"),
- isNaN: jasmine.createSpy("window.isNaN")
- };
- });
-
- afterEach(function () {
- index = null;
- delete GLOBAL.JNEXT;
- delete GLOBAL.window;
- delete GLOBAL.PluginResult;
- });
-
- describe("index.search", function () {
- it("correctly parses args to pass down to native (with filter)", function () {
- var findOptions = new ContactFindOptions("test"),
- args = {
- "0": encodeURIComponent(JSON.stringify(["phoneNumbers", "emails"])),
- "1": encodeURIComponent(JSON.stringify(findOptions)),
- "callbackId": encodeURIComponent(JSON.stringify("Contacts12345"))
- },
- jnextArgs = {
- "_eventId": "Contacts12345",
- "fields": ["phoneNumbers", "emails"],
- "options": {
- "filter": [
- { "fieldValue": "test" }
- ]
- }
- };
- index.search(function () {}, function () {}, args, {});
- expect(JNEXT.invoke).toHaveBeenCalledWith(123, 'find ' + JSON.stringify(jnextArgs));
- expect(result.noResult).toHaveBeenCalledWith(true);
- });
-
- it("correctly parses args to pass down to native (with no filter)", function () {
- var findOptions = new ContactFindOptions(),
- args = {
- "0": encodeURIComponent(JSON.stringify(["phoneNumbers", "emails"])),
- "1": encodeURIComponent(JSON.stringify(findOptions)),
- "callbackId": encodeURIComponent(JSON.stringify("Contacts12345"))
- },
- jnextArgs = {
- "_eventId": "Contacts12345",
- "fields": ["phoneNumbers", "emails"],
- "options": {
- "filter": []
- }
- };
- index.search(function () {}, function () {}, args, {});
- expect(JNEXT.invoke).toHaveBeenCalledWith(123, 'find ' + JSON.stringify(jnextArgs));
- expect(result.noResult).toHaveBeenCalledWith(true);
- });
- });
-
- describe("index.save", function () {
- it("calls JNEXT save with the correct param if contactId provided", function () {
- var contactProps = {
- "id": "123"
- },
- args = {
- "0": encodeURIComponent(JSON.stringify(contactProps)),
- "callbackId": encodeURIComponent(JSON.stringify("Contacts12345"))
- };
-
- window.parseInt.andCallFake(function () {
- return 123;
- });
- index.save(function () {}, function () {}, args, {});
- expect(JNEXT.invoke).toHaveBeenCalledWith(123, 'save ' + JSON.stringify({"id": 123, "_eventId": "Contacts12345"}));
- expect(result.noResult).toHaveBeenCalledWith(true);
- });
-
- it("properly converts birthdays for native", function () {
- var contactProps = {
- birthday: 1367259069028,
- },
- args = {
- "0": encodeURIComponent(JSON.stringify(contactProps)),
- "callbackId": encodeURIComponent(JSON.stringify("Contacts12345"))
- },
- processedArgs = {
- "birthday": "Mon Apr 29 2013",
- "_eventId": "Contacts12345"
- };
-
- index.save(function () {}, function () {}, args, {});
- expect(JNEXT.invoke).toHaveBeenCalledWith(123, 'save ' + JSON.stringify(processedArgs));
- expect(result.noResult).toHaveBeenCalledWith(true);
- });
-
- it("processes emails contactFeild array", function () {
- var contactProps = {
- "emails": [
- { "value": "a@c.com" },
- { "type" : "home", "value": "a@b.com" }
- ]
- },
- args = {
- "0": encodeURIComponent(JSON.stringify(contactProps)),
- "callbackId": encodeURIComponent(JSON.stringify("Contacts12345"))
- },
- processedArgs = {
- "emails": [
- { "type": "home", "value": "a@c.com" },
- { "type": "home", "value": "a@b.com" },
- ],
- "_eventId": "Contacts12345"
- };
- index.save(function () {}, function () {}, args, {});
- expect(JNEXT.invoke).toHaveBeenCalledWith(123, 'save ' + JSON.stringify(processedArgs));
- expect(result.noResult).toHaveBeenCalledWith(true);
-
- });
-
- });
-
- describe("index.remove", function () {
- it("calls JNEXT remove with the correct params for valid contactId", function () {
- var args = {
- "0": encodeURIComponent(JSON.stringify(123)),
- "callbackId": encodeURIComponent(JSON.stringify("Contacts12345"))
- };
-
- window.parseInt.andCallFake(function () {
- return 123;
- });
- index.remove(function () {}, function () {}, args, {});
- expect(JNEXT.invoke).toHaveBeenCalledWith(123, 'remove ' + JSON.stringify({"contactId": 123, "_eventId": "Contacts12345"}));
- expect(result.noResult).toHaveBeenCalledWith(true);
- });
-
- it("calls callbackError if invalid ID", function () {
- var args = {
- "0": encodeURIComponent(JSON.stringify("asdfas")),
- "callbackId": encodeURIComponent(JSON.stringify("Contacts12345"))
- };
-
- window.isNaN.andCallFake(function() {
- return true;
- });
- index.remove(function () {}, function () {}, args, {});
- expect(result.error).toHaveBeenCalledWith(ContactError.UNKNOWN_ERROR);
- expect(result.noResult).toHaveBeenCalledWith(false);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/Device/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Device/index.js b/blackberry10/bin/test/plugins/Device/index.js
deleted file mode 100644
index 09d9135..0000000
--- a/blackberry10/bin/test/plugins/Device/index.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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("Device", function () {
-
- var _apiDir = __dirname + "./../../../../plugins/Device/src/blackberry10/",
- index,
- result = {
- ok: jasmine.createSpy()
- };
-
- beforeEach(function () {
- index = require(_apiDir + "index");
- });
-
- afterEach(function () {
- index = null;
- });
-
- describe("getDeviceInfo", function () {
- beforeEach(function () {
- GLOBAL.window = {
- qnx: {
- webplatform: {
- device: {
- }
- }
- }
- };
- GLOBAL.PluginResult = function () {
- return result;
- };
- });
-
- afterEach(function () {
- delete GLOBAL.window;
- delete GLOBAL.PluginResult;
- });
-
- it("calls ok with the Device info", function () {
- var mockedDevice = {
- scmBundle: "1.0.0.0",
- modelName: "q10",
- devicePin: (new Date()).getTime()
- };
-
- result.ok = jasmine.createSpy().andCallFake(function (deviceInfo) {
- expect(deviceInfo.platform).toEqual("blackberry10");
- expect(deviceInfo.version).toEqual(mockedDevice.scmBundle);
- expect(deviceInfo.model).toEqual(mockedDevice.modelName);
- expect(deviceInfo.uuid).toEqual(mockedDevice.devicePin);
- expect(deviceInfo.cordova).toBeDefined();
- });
-
- window.qnx.webplatform.device = mockedDevice;
-
- index.getDeviceInfo();
-
- expect(result.ok).toHaveBeenCalled();
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/Geolocation/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Geolocation/index.js b/blackberry10/bin/test/plugins/Geolocation/index.js
deleted file mode 100644
index 5e06d83..0000000
--- a/blackberry10/bin/test/plugins/Geolocation/index.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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 ('geolocation', function () {
- var _apiDir = __dirname + "./../../../../plugins/Geolocation/src/blackberry10/",
- mockedPluginResult,
- geolocationIndex,
- mockedNavigator = {
- geolocation: {
- getCurrentPosition: jasmine.createSpy(),
- watchPosition: jasmine.createSpy().andReturn('1337'),
- clearWatch: jasmine.createSpy()
- }
- },
- noop = function () {};
-
- beforeEach (function() {
- mockedPluginResult = {
- callbackOk: jasmine.createSpy(),
- error: jasmine.createSpy(),
- noResult: jasmine.createSpy(),
- ok: jasmine.createSpy()
- };
-
- GLOBAL.PluginResult = function () {
- return mockedPluginResult;
- };
-
- GLOBAL.navigator = mockedNavigator;
- geolocationIndex = require(_apiDir + 'index');
- });
-
- afterEach(function () {
- delete require.cache[require.resolve(_apiDir + 'index')];
- delete GLOBAL.PluginResult;
- });
-
- describe('getLocation property', function() {
- it('calls navigator and result.noResult after declarations', function() {
- geolocationIndex.getLocation(noop,noop,{});
- expect(mockedNavigator.geolocation.getCurrentPosition).toHaveBeenCalled();
- expect(mockedPluginResult.noResult).toHaveBeenCalledWith(true);
- });
- });
-
- describe('addWatch property', function() {
- it('calls navigator to initialize id and calls result.noResult(true)', function() {
- geolocationIndex.addWatch(noop,noop,{});
- expect(mockedNavigator.geolocation.watchPosition).toHaveBeenCalled();
- expect(mockedPluginResult.noResult).toHaveBeenCalledWith(true);
- });
- });
-
- describe('clearWatch property', function() {
- it('calls navigator.geolocation.clearWatch(id) if id exists and calls result.ok', function () {
- geolocationIndex.addWatch(noop,noop,{});
- geolocationIndex.clearWatch(noop,noop,{});
- expect(mockedNavigator.geolocation.clearWatch).toHaveBeenCalledWith('1337');
- expect(mockedPluginResult.ok).toHaveBeenCalledWith(null, false);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/Logger/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Logger/index.js b/blackberry10/bin/test/plugins/Logger/index.js
deleted file mode 100644
index cec4556..0000000
--- a/blackberry10/bin/test/plugins/Logger/index.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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("Logger", function () {
-
- var _apiDir = __dirname + "./../../../../plugins/Logger/src/blackberry10/",
- index,
- result = {
- noResult: jasmine.createSpy("noResult")
- };
-
- beforeEach(function () {
- index = require(_apiDir + "index");
- });
-
- afterEach(function () {
- index = null;
- });
-
- describe("logLevel", function () {
- beforeEach(function () {
- spyOn(console, "log");
- GLOBAL.PluginResult = function () {
- return result;
- };
- });
-
- afterEach(function () {
- delete GLOBAL.PluginResult;
- });
-
- it("calls console.log", function () {
- index.logLevel(function () {}, function () {}, ["%22ERROR%22", "%22message%22"]);
- expect(console.log).toHaveBeenCalledWith("ERROR: message");
- expect(result.noResult).toHaveBeenCalledWith(false);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/Media/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Media/index.js b/blackberry10/bin/test/plugins/Media/index.js
deleted file mode 100644
index 2b49bd4..0000000
--- a/blackberry10/bin/test/plugins/Media/index.js
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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 ('media', function () {
- var _apiDir = __dirname + "./../../../../plugins/Media/src/blackberry10/",
- mockedPluginResult,
- mockedWebview,
- mockedaudio,
- mediaindex,
- noop = function () {};
-
- beforeEach (function() {
- mockedWebview = {
- allowWebEvent: jasmine.createSpy(),
- onDialogRequested: jasmine.createSpy()
- };
-
- GLOBAL.qnx = {
- webplatform: {
- getWebViews: function () {
- return {0: mockedWebview};
- }
- }
- };
-
- mockedPluginResult = {
- error: jasmine.createSpy(),
- ok: jasmine.createSpy()
- };
-
- GLOBAL.PluginResult = function () {
- return mockedPluginResult;
- };
-
- mockedaudio = {
- play: jasmine.createSpy(),
- pause: jasmine.createSpy(),
- currentTime: jasmine.createSpy(),
- duration: jasmine.createSpy(),
- src: jasmine.createSpy()
- };
- GLOBAL.Audio = jasmine.createSpy().andReturn(mockedaudio);
- mediaindex = require(_apiDir + 'index');
- });
-
- afterEach(function () {
- delete require.cache[require.resolve(_apiDir + 'index')];
- delete GLOBAL.qnx;
- delete GLOBAL.PluginResult;
- delete GLOBAL.Audio;
- });
-
- describe("create property", function() {
- it('will call result.error with invalid args', function () {
- mediaindex.create(noop, noop, {});
- expect(mockedPluginResult.error).toHaveBeenCalledWith(jasmine.any(String));
- });
-
- it('will create a new Audio object if invalid args[1]', function() {
- mediaindex.create(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify("42"))}
- );
- expect(Audio).toHaveBeenCalled();
- expect(mockedWebview.allowWebEvent).toHaveBeenCalledWith('DialogRequested');
- expect(mockedWebview.onDialogRequested).toBeDefined();
- expect(mockedPluginResult.ok).toHaveBeenCalled();
- });
-
- it('will create a new Audio object if valid args[1]', function () {
- mediaindex.create(
- noop,
- noop,
- {
- 0: encodeURIComponent(JSON.stringify('1337')),
- 1: encodeURIComponent(JSON.stringify('11'))
- }
- );
- expect(Audio).toHaveBeenCalledWith('11');
- expect(mockedPluginResult.ok).toHaveBeenCalled();
- });
- });
-
- describe('startPlayingAudio property', function () {
- it('will error message if args[0] does not exist', function () {
- mediaindex.startPlayingAudio(
- noop,
- noop,
- {}
- );
- expect(mockedPluginResult.error).toHaveBeenCalled();
- });
-
- it('will error message if audio does not exist', function () {
- mediaindex.startPlayingAudio(
- noop,
- noop,
- {0:1} //ensuring that args[0] exists
- );
- expect(mockedPluginResult.error).toHaveBeenCalledWith('Audio object has not been initialized');
- });
-
- it('will call audio.play() and result.ok() when audio exists', function () {
- mediaindex.create(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
- expect(Audio).toHaveBeenCalled();
-
- mediaindex.startPlayingAudio(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
-
- expect(mockedaudio.play).toHaveBeenCalled();
- expect(mockedPluginResult.ok).toHaveBeenCalled();
- });
- });
-
- describe('stopPlayingAudio property', function () {
- it('will error message if args[0] does not exist', function () {
- mediaindex.stopPlayingAudio(
- noop,
- noop,
- {}
- );
- expect(mockedPluginResult.error).toHaveBeenCalled();
- });
-
- it('will error message if audio does not exist', function () {
- mediaindex.stopPlayingAudio(
- noop,
- noop,
- {0:1}
- );
- expect(mockedPluginResult.error).toHaveBeenCalledWith('Audio Object has not been initialized');
- });
-
- it('will call audio.pause(), audio.currentTime() and result.ok() when audio exists', function () {
- mediaindex.create (
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
-
- mediaindex.stopPlayingAudio(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
- expect(mockedaudio.pause).toHaveBeenCalled();
- expect(mockedaudio.currentTime).toEqual(0);
- });
- });
-
- describe('seekToAudio property', function () {
- it('will error message if args[0] does not exist', function () {
- mediaindex.seekToAudio(
- noop,
- noop,
- {}
- );
- expect(mockedPluginResult.error).toHaveBeenCalled();
- });
-
- it('will error message when audio does not exist', function () {
- mediaindex.seekToAudio(
- noop,
- noop,
- {0:1}
- );
- expect(mockedPluginResult.error).toHaveBeenCalledWith('Audio Object has not been initialized');
- });
-
- it('will error message if args[1] does not exist', function () {
- mediaindex.create(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
-
- mediaindex.seekToAudio(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
- expect(mockedPluginResult.error).toHaveBeenCalledWith('Media seek time argument not found');
- });
-
- it('will set audio.currentTime and call result.ok() with no error', function () {
- mediaindex.create(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
-
- mediaindex.seekToAudio(
- noop,
- noop,
- {
- 0: encodeURIComponent(JSON.stringify('1337')),
- 1: encodeURIComponent(JSON.stringify('11'))
- }
- );
- expect(mockedaudio.currentTime).not.toEqual(0);
- expect(mockedPluginResult.ok).toHaveBeenCalled();
- });
-
- it('will call result.error when there is an error', function () {
- mediaindex.create(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
-
- mockedPluginResult.ok.andCallFake(function () {throw 'testerror';});
-
- mediaindex.seekToAudio(
- noop,
- noop,
- {
- 0: encodeURIComponent(JSON.stringify('1337')),
- 1: encodeURIComponent(JSON.stringify('11'))
- }
- );
- expect(mockedPluginResult.error).toHaveBeenCalledWith('Error seeking audio: testerror');
- });
- });
-
- describe('pausePlayingAudio property', function () {
- it('will error message if args[0] does not exist', function () {
- mediaindex.pausePlayingAudio (
- noop,
- noop,
- {}
- );
- expect(mockedPluginResult.error).toHaveBeenCalled();
- });
-
- it('will error message when audio does not exist', function () {
- mediaindex.pausePlayingAudio(
- noop,
- noop,
- {0:1}
- );
- expect(mockedPluginResult.error).toHaveBeenCalledWith('Audio Object has not been initialized');
- });
-
- it('will call audio.pause() when args[0] and audio exists', function () {
- mediaindex.create(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
-
- mediaindex.pausePlayingAudio(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
- expect(mockedaudio.pause).toHaveBeenCalled();
- });
- });
-
- describe('getCurrentPositionAudio property', function () {
- it('will error message if args[0] does not exist', function () {
- mediaindex.getCurrentPositionAudio(
- noop,
- noop,
- {}
- );
- expect(mockedPluginResult.error).toHaveBeenCalled();
- });
-
- it('will error message if audio does not exist', function () {
- mediaindex.getCurrentPositionAudio(
- noop,
- noop,
- {0:1}
- );
- expect(mockedPluginResult.error).toHaveBeenCalledWith('Audio Object has not been initialized');
- });
-
- it('will call result.ok(audio.currentTime) when audio and args[0] exists', function () {
- mediaindex.create(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
-
- mediaindex.getCurrentPositionAudio(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
- expect(mockedPluginResult.ok).toHaveBeenCalledWith(mockedaudio.currentTime);
- });
- });
-
- describe('getDuration property', function () {
- it('will error message if args[0] does not exist', function () {
- mediaindex.getDuration(
- noop,
- noop,
- {}
- );
- expect(mockedPluginResult.error).toHaveBeenCalled();
- });
-
- it('will error message if audio does not exist', function () {
- mediaindex.getDuration (
- noop,
- noop,
- {0:1}
- );
- expect(mockedPluginResult.error).toHaveBeenCalledWith('Audio Object has not been initialized');
- });
-
- it('will call result.ok(audio.duration) when audio and args[0] exist', function () {
- mediaindex.create(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
-
- mediaindex.getDuration(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
- expect(mockedPluginResult.ok).toHaveBeenCalledWith(mockedaudio.duration);
- });
- });
-
- describe('startRecordingAudio and stopRecordingAudio property', function () {
- it('will say not supported for start recording', function () {
- mediaindex.startRecordingAudio();
- expect(mockedPluginResult.error).toHaveBeenCalled();
- });
-
- it('will say not supported for stop recording', function () {
- mediaindex.stopRecordingAudio();
- expect(mockedPluginResult.error).toHaveBeenCalled();
- });
- });
-
- describe('release property', function () {
- it('will error message if args[0] does not exist', function () {
- mediaindex.release(
- noop,
- noop,
- {}
- );
- expect(mockedPluginResult.error).toHaveBeenCalled();
- });
-
- it('will set audio to be undefined', function () {
- mediaindex.create(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
-
- mediaindex.release(
- noop,
- noop,
- {0: encodeURIComponent(JSON.stringify('1337'))}
- );
- expect(mockedaudio.src).not.toBeDefined();
- expect(mockedPluginResult.ok).toHaveBeenCalled();
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/NetworkStatus/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/NetworkStatus/index.js b/blackberry10/bin/test/plugins/NetworkStatus/index.js
deleted file mode 100644
index ac87390..0000000
--- a/blackberry10/bin/test/plugins/NetworkStatus/index.js
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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("NetworkStatus", function () {
- var _apiDir = __dirname + "./../../../../plugins/NetworkStatus/src/blackberry10/",
- index,
- result = {
- ok: jasmine.createSpy(),
- error: jasmine.createSpy()
- };
-
- beforeEach(function () {
- index = require(_apiDir + "index");
- });
-
- afterEach(function () {
- index = null;
- });
-
- describe("getConnectionInfo", function () {
- beforeEach(function () {
- GLOBAL.window = {
- qnx: {
- webplatform: {
- device: {
- }
- }
- }
- };
- GLOBAL.PluginResult = function () {
- return result;
- };
- });
-
- afterEach(function () {
- delete GLOBAL.window;
- delete GLOBAL.PluginResult;
- });
-
- function testConnection(expectedResult, mockedType, mockedTechnology) {
- var mockedDevice = {
- activeConnection: {
- type: mockedType,
- technology: mockedTechnology
- }
- };
-
- if (mockedType) {
- window.qnx.webplatform.device = mockedDevice;
- }
-
- index.getConnectionInfo();
-
- expect(result.ok).toHaveBeenCalledWith(expectedResult);
- expect(result.error).not.toHaveBeenCalled();
- }
-
- it("calls success with a wired connection", function () {
- testConnection("ethernet", "wired");
- });
-
- it("calls success with a wifi connection", function () {
- testConnection("wifi", "wifi");
- });
-
- it("calls success with no connection", function () {
- testConnection("none", "none");
- });
-
- it("calls success with a cellular edge connection", function () {
- testConnection("2g", "cellular", "edge");
- });
-
- it("calls success with a cellular gsm connection", function () {
- testConnection("2g", "cellular", "gsm");
- });
-
- it("calls success with a cellular evdo connection", function () {
- testConnection("3g", "cellular", "evdo");
- });
-
- it("calls success with a cellular umts connection", function () {
- testConnection("3g", "cellular", "umts");
- });
-
- it("calls success with a lte connection", function () {
- testConnection("4g", "cellular", "lte");
- });
-
- it("calls success with a cellular connection", function () {
- testConnection("cellular", "cellular");
- });
-
- it("defaults to none if no connection is found", function () {
- testConnection("none");
- });
-
- it("defaults to unknown if connection type doesn't exist", function () {
- testConnection("unknown", "fakeConnectionType");
- });
-
- });
-
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/Notification/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Notification/index.js b/blackberry10/bin/test/plugins/Notification/index.js
deleted file mode 100644
index 8d10e25..0000000
--- a/blackberry10/bin/test/plugins/Notification/index.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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 mockAndTestDialog(htmlmessage, title, dialogType, buttonLabel) {
- GLOBAL.qnx = {
- webplatform: {
- getWebViews: function () {
- var webviews = [{}, {},
- {//overlayWebview
- dialog: {
- show: function(messageObj, callback) {
- expect(messageObj.title).toEqual(title);
- expect(messageObj.htmlmessage).toEqual(htmlmessage);
- expect(messageObj.dialogType).toEqual(dialogType);
- expect(messageObj.optionalButtons).toEqual(buttonLabel);
- expect(typeof callback).toEqual("function");
- }
- }
- }];
- return webviews;
- }
- }
- };
-
-}
-
-describe("Notification", function () {
- var _apiDir = __dirname + "./../../../../plugins/Notification/src/blackberry10/",
- index,
- success = function() {},
- fail = function() {},
- result = {
- error: jasmine.createSpy(),
- noResult: jasmine.createSpy()
- },
- args = {
- 0: "%22Dialog%20message.%22",
- 1: "%22Dialog%20Title%22",
- 2: "%22Continue%22"
- };
-
- beforeEach(function () {
- index = require(_apiDir + "index");
-
- GLOBAL.PluginResult = function () {
- return result;
- };
- });
-
- afterEach(function () {
- delete require.cache[require.resolve(_apiDir + "index")];
- delete GLOBAL.qnx;
- delete GLOBAL.PluginResult;
- });
-
- describe("alert", function () {
- it("fails with invalid number of args", function () {
- index.alert(success, fail, {}, {});
- expect(result.error).toHaveBeenCalledWith("Notification action - alert arguments not found.");
- });
-
- it("calls dialog.show with correct params", function () {
- mockAndTestDialog("Dialog message.", "Dialog Title", "CustomAsk", ["Continue"]);
- index.alert(success, fail, args, {});
- expect(result.noResult).toHaveBeenCalled();
- });
- });
-
- describe("confirm", function () {
- it("fails with invalid number of args", function () {
- index.confirm(success, fail, {}, {});
- expect(result.error).toHaveBeenCalledWith("Notification action - confirm arguments not found.");
- });
-
- it("calls dialog.show with correct params", function () {
- mockAndTestDialog("Dialog message.", "Dialog Title", "CustomAsk", ["Continue"]);
- index.confirm(success, fail, args, {});
- expect(result.noResult).toHaveBeenCalled();
- });
-
- it("calls dialog.show with correct params [deprecated buttonArg]", function () {
- var args = {
- 0: "%22Dialog%20message.%22",
- 1: "%22Dialog%20Title%22",
- 2: "%22Continue,Cancel%22"
- };
-
- mockAndTestDialog("Dialog message.", "Dialog Title", "CustomAsk", ["Continue", "Cancel"]);
- index.confirm(success, fail, args, {});
- expect(result.noResult).toHaveBeenCalled();
- });
- });
-
- describe("prompt", function () {
- it("fails with invalid number of args", function () {
- index.prompt(success, fail, {}, {});
- expect(result.error).toHaveBeenCalledWith("Notification action - prompt arguments not found.");
- });
-
- it("calls dialog.show with correct params", function () {
- mockAndTestDialog("Dialog message.", "Dialog Title", "JavaScriptPrompt", ["Continue"]);
- index.prompt(success, fail, args, {});
- expect(result.noResult).toHaveBeenCalled();
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/bin/test/plugins/SplashScreen/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/SplashScreen/index.js b/blackberry10/bin/test/plugins/SplashScreen/index.js
deleted file mode 100644
index 658ce3d..0000000
--- a/blackberry10/bin/test/plugins/SplashScreen/index.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-* Copyright 2013 Research In Motion Limited.
-*
-* Licensed 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("SplashScreen", function () {
- var _apiDir = __dirname + "./../../../../plugins/SplashScreen/src/blackberry10/",
- index,
- mockedEnv = {
- response: {
- send: jasmine.createSpy()
- }
- },
- mockedApplication = {
- windowVisible: undefined
- };
-
- beforeEach(function () {
- index = require(_apiDir + "index");
- mockedEnv.response.send.reset();
- });
-
- afterEach(function () {
- index = null;
- delete require.cache[require.resolve(_apiDir + "index")];
- });
- describe("show", function () {
- beforeEach(function () {
- GLOBAL.PluginResult = function (args, env) {};
- GLOBAL.PluginResult.prototype.error = jasmine.createSpy();
- });
-
- afterEach(function () {
- delete GLOBAL.PluginResult;
- });
-
- it("calls PluginResult.error if show is called", function () {
- index.show();
-
- expect(PluginResult.prototype.error).toHaveBeenCalledWith("Not supported on platform", false);
- });
- });
-
- describe("hide", function () {
- beforeEach(function () {
- GLOBAL.window = {
- qnx: {
- webplatform: {
- getApplication: function () {
- return mockedApplication;
- }
- }
- }
- };
-
- GLOBAL.PluginResult = function (args, env) {};
- GLOBAL.PluginResult.prototype.ok = jasmine.createSpy();
- });
-
- afterEach(function () {
- delete GLOBAL.window;
- delete GLOBAL.PluginResult;
- });
-
- it("calls PluginResult.ok if hide is called", function () {
- index.hide();
-
- expect(mockedApplication.windowVisible).toBeTruthy();
- expect(PluginResult.prototype.ok).toHaveBeenCalledWith(undefined, false);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/3a53fb75/blackberry10/scripts/test.js
----------------------------------------------------------------------
diff --git a/blackberry10/scripts/test.js b/blackberry10/scripts/test.js
index c1b70c2..537652c 100644
--- a/blackberry10/scripts/test.js
+++ b/blackberry10/scripts/test.js
@@ -22,8 +22,7 @@ module.exports = function (done, custom) {
[
"framework/test",
"bin/test/cordova/integration",
- "bin/test/cordova/unit",
- "bin/test/plugins"
+ "bin/test/cordova/unit"
];
utils.copyFile('bin/lib/utils.js', 'bin/templates/project/cordova/lib/', '../');
jasmine.executeSpecsInFolder({
@@ -31,7 +30,7 @@ module.exports = function (done, custom) {
'onComplete': function (runner) {
var failedCount = runner.results().failedCount;
((done && typeof done === "function") ? done : process.exit)(failedCount);
- },
+ },
'isVerbose': false,
'showColors': true
});