webworks accelerometer tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/e1be8e7e Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/e1be8e7e Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/e1be8e7e Branch: refs/heads/master Commit: e1be8e7e798287787ad1387b3a3e4a37ac267d53 Parents: 1e2d5c0 Author: Matt Lantz <[email protected]> Authored: Wed Nov 7 17:33:02 2012 -0500 Committer: Gord Tanner <[email protected]> Committed: Mon Nov 12 09:42:28 2012 -0500 ---------------------------------------------------------------------- test/blackberry/webworks/test.accelerometer.js | 62 +++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e1be8e7e/test/blackberry/webworks/test.accelerometer.js ---------------------------------------------------------------------- diff --git a/test/blackberry/webworks/test.accelerometer.js b/test/blackberry/webworks/test.accelerometer.js new file mode 100644 index 0000000..8c726d7 --- /dev/null +++ b/test/blackberry/webworks/test.accelerometer.js @@ -0,0 +1,62 @@ +/* + * + * 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("accelerometer", function () { + var accelerometer = require('cordova/plugin/webworks/accelerometer'); + + describe("start", function() { + it("should start webworks watching the accelerometer", function() { + spyOn(window, "removeEventListener"); + spyOn(window, "addEventListener"); + + var callback = function(motion){}, + win = function(){}, + fail = function(){}, + args = {x:1,y:2,z:3}, + aStart = accelerometer.start(args, win, fail); + + expect(window.removeEventListener).toHaveBeenCalledWith("devicemotion", undefined); + + expect(window.addEventListener).toHaveBeenCalledWith("devicemotion", jasmine.any(Function)); + + window.removeEventListener.reset(); + window.addEventListener.reset(); + + expect(aStart.status).toBe(0); + expect(aStart.message).toBe('WebWorks Is On It'); + + }); + }); + + describe("stop", function() { + it("should stop webworks from watching the accelerometer", function() { + spyOn(window, "removeEventListener"); + var aStop = accelerometer.stop(); + + expect(window.removeEventListener).toHaveBeenCalled(); + expect(aStop.status).toBe(0); + expect(aStop.message).toBe('WebWorks Is On It'); + + }); + }); + +}); +
