spec/tests/orientation.tests.js
changeset 0 54063d8b0412
equal deleted inserted replaced
-1:000000000000 0:54063d8b0412
       
     1 Tests.prototype.OrientationTests = function() {	
       
     2 	module('Orientation (navigator.orientation)');
       
     3 	test("should exist", function() {
       
     4   		expect(1);
       
     5   		ok(navigator.orientation != null, "navigator.orientation should not be null.");
       
     6 	});
       
     7 	test("should have an initially null lastPosition property", function() {
       
     8   		expect(1);
       
     9   		ok(typeof navigator.orientation.currentOrientation != 'undefined' && navigator.orientation.currentOrientation == null, "navigator.orientation.currentOrientation should be initially null.");
       
    10 	});
       
    11 	test("should contain a getCurrentOrientation function", function() {
       
    12 		expect(2);
       
    13 		ok(typeof navigator.orientation.getCurrentOrientation != 'undefined' && navigator.orientation.getCurrentOrientation != null, "navigator.orientation.getCurrentOrientation should not be null.");
       
    14 		ok(typeof navigator.orientation.getCurrentOrientation == 'function', "navigator.orientation.getCurrentOrientation should be a function.");
       
    15 	});
       
    16 	test("should contain a watchOrientation function", function() {
       
    17 		expect(2);
       
    18 		ok(typeof navigator.orientation.watchOrientation != 'undefined' && navigator.orientation.watchOrientation != null, "navigator.orientation.watchOrientation should not be null.");
       
    19 		ok(typeof navigator.orientation.watchOrientation == 'function', "navigator.orientation.watchOrientation should be a function.");
       
    20 	});
       
    21 	// TODO: add tests for DisplayOrientation constants?
       
    22 	test("getCurrentOrientation success callback should be called with an Orientation enumeration", function() {
       
    23 		expect(2);
       
    24 		stop(tests.TEST_TIMEOUT);
       
    25 		var win = function(orient) {
       
    26 			ok(0 <= orient <= 6, "Position object returned in getCurrentPosition success callback is a valid DisplayOrientation value.");
       
    27 			equals(orient, navigator.orientation.currentOrientation, "Orientation value returned in getCurrentOrientation success callback equals navigator.orientation.currentOrientation.");
       
    28 			start();
       
    29 		};
       
    30 		var fail = function() { start(); };
       
    31 		navigator.orientation.getCurrentOrientation(win, fail);
       
    32 	});
       
    33 	// TODO: Need to test watchPosition success callback, test that makes sure clearPosition works (how to test that a timer is getting cleared?)
       
    34 };