Fix some tests

This commit is contained in:
Neil Stalker
2013-06-29 15:18:02 +01:00
parent eab0fc16ea
commit 3dacaaa512
9 changed files with 53 additions and 94 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
/// <reference path="breeze-1.0.d.ts" />
import breeze = module(Breeze);
import core = module(BreezeCore);
import breeze = Breeze;
import core = BreezeCore;
function test_dataType() {
var typ = breeze.DataType.DateTime;
+1 -1
View File
@@ -1,6 +1,6 @@
/// <reference path="breeze.d.ts" />
import core = module(breezeCore);
import core = breezeCore;
function test_dataType() {
var typ = breeze.DataType.DateTime;
+1 -1
View File
@@ -748,7 +748,7 @@ declare module breeze {
constructor (name: string, validatorFn: ValidatorFunction, context?: any);
static boolean(): Validator;
static bool(): Validator;
static byte(): Validator;
static date(): Validator;
static duration(): Validator;
+1
View File
@@ -40,6 +40,7 @@ $('#example3').glDatePicker(
{
date: new Date(0, 0, 1),
data: { message: 'Happy New Year!' },
repeatMonth: false,
repeatYear: true
},
],
+7 -7
View File
@@ -24,7 +24,7 @@ class Assert {
static passedTests: number = 0;
static Results() {
console.log('Tests succeeded - ' + passedTests + '/' + totalTests + '; Tests failed - ' + (totalTests - passedTests) + '/' + totalTests);
console.log('Tests succeeded - ' + this.passedTests + '/' + this.totalTests + '; Tests failed - ' + (this.totalTests - this.passedTests) + '/' + this.totalTests);
}
static AssertionFailed(actual: any, expected: any, test: string) {
@@ -32,21 +32,21 @@ class Assert {
}
static Equal(actual: any, expected: any, test?: string) {
totalTests++;
this.totalTests++;
if (actual === expected) {
passedTests++;
this.passedTests++;
return;
}
AssertionFailed(actual, expected, test);
this.AssertionFailed(actual, expected, test);
}
static NotEqual(actual: any, expected: any, test?: string) {
totalTests++;
this.totalTests++;
if (actual !== expected) {
passedTests++;
this.passedTests++;
return;
}
AssertionFailed(actual, expected, test);
this.AssertionFailed(actual, expected, test);
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
/// <reference path="LeapMotionTS.d.ts" />
import Leap = module('../LeapMotionTS');
import Leap = module('LeapMotionTS');
var controller: Leap.Controller = new Leap.Controller();
controller.addEventListener(Leap.LeapEvent.LEAPMOTION_FRAME, (event: Leap.LeapEvent) => {
+36 -78
View File
@@ -73,9 +73,6 @@ function test_camera() {
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
}
function test_capture() {
@@ -120,64 +117,12 @@ function test_capture() {
navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};
navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 2 });
function captureSuccess(mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
uploadFile(mediaFiles[i]);
}
}
function captureError(error) {
var msg = 'An error occurred during capture: ' + error.code;
navigator.notification.alert(msg, null, 'Uh oh!');
}
function captureImage() {
navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 2 });
}
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile.fullPath,
name = mediaFile.name;
ft.upload(path,
"http://my.domain.com/upload.php",
function (result) {
console.log('Upload success: ' + result.responseCode);
console.log(result.bytesSent + ' bytes sent');
},
function (error) {
console.log('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
}
function captureSuccess(mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
uploadFile(mediaFiles[i]);
}
}
function captureError(error) {
var msg = 'An error occurred during capture: ' + error.code;
navigator.notification.alert(msg, null, 'Uh oh!');
}
function captureVideo() {
navigator.device.capture.captureVideo(captureSuccess, captureError, { limit: 2 });
}
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile.fullPath,
name = mediaFile.name;
ft.upload(path,
"http://my.domain.com/upload.php",
function (result) {
console.log('Upload success: ' + result.responseCode);
console.log(result.bytesSent + ' bytes sent');
},
function (error) {
console.log('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
}
}
function test_compass() {
@@ -191,9 +136,10 @@ function test_compass() {
function onError(compassError) {
alert('Compass Error: ' + compassError.code);
}
}
function test_compass2() {
var watchID = null;
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
startWatch();
@@ -215,7 +161,9 @@ function test_compass() {
function onError(compassError) {
alert('Compass error: ' + compassError.code);
}
}
function test_compass3() {
var watchID = null;
function startWatch() {
var options = { frequency: 3000 };
watchID = navigator.compass.watchHeading(onSuccess, onError, options);
@@ -281,7 +229,17 @@ function test_contacts() {
console.log("Original contact name = " + contact.name.givenName);
console.log("Cloned contact name = " + clone.name.givenName);
contact.remove(onSuccess, onError);
}
function test_contacts2() {
function onSuccess(contacts) {
for (var i = 0; i < contacts.length; i++) {
console.log("Display Name = " + contacts[i].displayName);
}
}
function onError(contactError) {
alert('onError!');
}
function onDeviceReady() {
var contact = navigator.contacts.create();
contact.displayName = "Plumber";
@@ -375,7 +333,8 @@ function test_file() {
function fail(evt) {
console.log(evt.target.error.code);
}
}
function test_file2() {
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
@@ -403,7 +362,8 @@ function test_file() {
function fail(error) {
console.log(error.code);
}
}
function test_file3() {
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
}
@@ -459,11 +419,6 @@ function test_file() {
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
var uri = encodeURI("http://some.server.com/upload.php");
var fileURI = "";
var options = new FileUploadOptions();
@@ -480,20 +435,21 @@ function test_file() {
function test_geolocation() {
var onSuccess = function (position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
};
function onError(error: GeolocationError) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function test_geolocation2() {
function onSuccess(position) {
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
@@ -606,7 +562,8 @@ function test_inAppBrowser() {
}
function test_media() {
var my_media = new Media(src, ()=>{}, ()=>{});
var src = '';
var my_media = new Media(src, () => { }, () => { });
var mediaTimer = setInterval(function () {
my_media.getCurrentPosition(
function (position) {
@@ -617,7 +574,7 @@ function test_media() {
function (e) {
console.log("Error getting pos=" + e);
}
);
);
}, 1000);
var counter = 0;
@@ -646,7 +603,8 @@ function test_media() {
my_media.pause();
}, 10000);
}
}
function test_media2() {
function playAudio(url) {
var my_media = new Media(url,
function () {
+2 -2
View File
@@ -1,6 +1,6 @@
/// <reference path="platform.d.ts" />
declare interface ITestContainer {
interface ITestContainer {
[name: string]: PlatformStatic;
}
@@ -54,7 +54,7 @@ function runTests() {
onFalse = (name: string) => {
return function () => {
return () => {
console.log('\tfailed on prop "' + name + '" for "' + n + '"');
}
}
+2 -2
View File
@@ -14,8 +14,8 @@ interface PlatformStatic {
ua?: string;
version?: string;
os?: PlatformOS;
parse(ua: string): PlatformStatic;
toString(): string;
parse?(ua: string): PlatformStatic;
toString?(): string;
}
interface PlatformOS {