mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
Cleaning out the asssets/www directory. This should house mobile-spec
This commit is contained in:
parent
ae8bc77ee7
commit
8ecfcb12c7
@ -1,208 +0,0 @@
|
||||
The MIT License
|
||||
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2009-2011 Rob Ellis, Brock Whitten, Brian LeRoux
|
||||
Copyright 2010-2011, IBM Corporation
|
||||
Copyright 2011 Adobe
|
||||
|
||||
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.
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
## Mobile Spec Suite ##
|
||||
|
||||
These specs are designed to run inside the mobile device that implements it - _it will fail in the DESKTOP browser_.
|
||||
|
||||
These set of tests is designed to be used with Cordova. You should initialize a fresh Cordova repository for a target platform and then toss these files into the www folder, replacing the
|
||||
contents.
|
||||
|
||||
Make sure you include Cordova-\*.js in the www folder. You also need to edit Cordova.js to reference the Cordova-\*.js file you are testing.
|
||||
For example, to test with Cordova-0.9.6.1, the Cordova.js file would be:
|
||||
|
||||
document.write('<script type="text/javascript" charset="utf-8" src="../Cordova-0.9.6.1.js"></script>');
|
||||
document.write('<script type="text/javascript" charset="utf-8" src="Cordova-0.9.6.1.js"></script>');
|
||||
|
||||
This is done so that you don't have to modify every HTML file when you want to test a new version of Cordova.
|
||||
|
||||
The goal is to test mobile device functionality inside a mobile browser.
|
||||
Where possible, the Cordova API lines up with HTML 5 spec. Maybe down
|
||||
the road we could use this spec for parts of HTML 5, too :)
|
@ -1,138 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
function roundNumber(num) {
|
||||
var dec = 3;
|
||||
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Acceleration
|
||||
//-------------------------------------------------------------------------
|
||||
var watchAccelId = null;
|
||||
|
||||
/**
|
||||
* Start watching acceleration
|
||||
*/
|
||||
var watchAccel = function() {
|
||||
console.log("watchAccel()");
|
||||
|
||||
// Success callback
|
||||
var success = function(a){
|
||||
document.getElementById('x').innerHTML = roundNumber(a.x);
|
||||
document.getElementById('y').innerHTML = roundNumber(a.y);
|
||||
document.getElementById('z').innerHTML = roundNumber(a.z);
|
||||
console.log("watchAccel success callback");
|
||||
};
|
||||
|
||||
// Fail callback
|
||||
var fail = function(e){
|
||||
console.log("watchAccel fail callback with error code "+e);
|
||||
stopAccel();
|
||||
setAccelStatus(Accelerometer.ERROR_MSG[e]);
|
||||
};
|
||||
|
||||
// Update acceleration every 1 sec
|
||||
var opt = {};
|
||||
opt.frequency = 1000;
|
||||
watchAccelId = navigator.accelerometer.watchAcceleration(success, fail, opt);
|
||||
|
||||
setAccelStatus("Running");
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop watching the acceleration
|
||||
*/
|
||||
var stopAccel = function() {
|
||||
console.log("stopAccel()");
|
||||
setAccelStatus("Stopped");
|
||||
if (watchAccelId) {
|
||||
navigator.accelerometer.clearWatch(watchAccelId);
|
||||
watchAccelId = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get current acceleration
|
||||
*/
|
||||
var getAccel = function() {
|
||||
console.log("getAccel()");
|
||||
|
||||
// Stop accel if running
|
||||
stopAccel();
|
||||
|
||||
// Success callback
|
||||
var success = function(a){
|
||||
document.getElementById('x').innerHTML = roundNumber(a.x);
|
||||
document.getElementById('y').innerHTML = roundNumber(a.y);
|
||||
document.getElementById('z').innerHTML = roundNumber(a.z);
|
||||
};
|
||||
|
||||
// Fail callback
|
||||
var fail = function(e){
|
||||
console.log("getAccel fail callback with error code "+e);
|
||||
setAccelStatus(Accelerometer.ERROR_MSG[e]);
|
||||
};
|
||||
|
||||
// Make call
|
||||
var opt = {};
|
||||
navigator.accelerometer.getCurrentAcceleration(success, fail, opt);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set accelerometer status
|
||||
*/
|
||||
var setAccelStatus = function(status) {
|
||||
document.getElementById('accel_status').innerHTML = status;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
console.log("accelerometer.init()");
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Acceleration</h1>
|
||||
<div id="info">
|
||||
<div id="accel_status">Stopped</div>
|
||||
<div><table width="100%">
|
||||
<tr><td width="20%">X:</td><td id="x"> </td></tr>
|
||||
<tr><td width="20%">Y:</td><td id="y"> </td></tr>
|
||||
<tr><td width="20%">Z:</td><td id="z"> </td></tr>
|
||||
</table></div>
|
||||
</div>
|
||||
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large"onclick="getAccel();">Get Acceleration</a>
|
||||
<a href="javascript:" class="btn large"onclick="watchAccel();">Start Watch</a>
|
||||
<a href="javascript:" class="btn large"onclick="stopAccel();">Clear Watch</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
@ -1,272 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Audio player
|
||||
//-------------------------------------------------------------------------
|
||||
var media1 = null;
|
||||
var media1Timer = null;
|
||||
var audioSrc = null;
|
||||
var recordSrc = "myRecording.mp3";
|
||||
|
||||
/**
|
||||
* Play audio
|
||||
*/
|
||||
function playAudio(url) {
|
||||
console.log("playAudio()");
|
||||
console.log(" -- media="+media1);
|
||||
|
||||
//var src = "http://neuga.s3.amazonaws.com/onclassical/strings-organ.mp3";
|
||||
var src = "http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3";
|
||||
//var src = "/android_asset/www/Jet_Sledding.mp4"; // no work
|
||||
//var src = "http://vprbbc.streamguys.net/vprbbc24.mp3"; // mp3 streaming
|
||||
|
||||
if (url) {
|
||||
src = url;
|
||||
}
|
||||
|
||||
// Stop playing if src is different from currently playing source
|
||||
if (src != audioSrc) {
|
||||
if (media1 != null) {
|
||||
stopAudio();
|
||||
media1 = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (media1 == null) {
|
||||
|
||||
|
||||
// TEST STREAMING AUDIO PLAYBACK
|
||||
//var src = "http://nunzioweb.com/misc/Bon_Jovi-Crush_Mystery_Train.mp3"; // works
|
||||
//var src = "http://nunzioweb.com/misc/Bon_Jovi-Crush_Mystery_Train.m3u"; // doesn't work
|
||||
//var src = "http://www.wav-sounds.com/cartoon/bugsbunny1.wav"; // works
|
||||
//var src = "http://www.angelfire.com/fl5/html-tutorial/a/couldyou.mid"; // doesn't work
|
||||
//var src = "MusicSearch/mp3/train.mp3"; // works
|
||||
//var src = "bryce.mp3"; // works
|
||||
//var src = "/android_asset/www/bryce.mp3"; // works
|
||||
|
||||
media1 = new Media(src,
|
||||
function() {
|
||||
console.log("playAudio():Audio Success");
|
||||
},
|
||||
function(err) {
|
||||
console.log("playAudio():Audio Error: "+err);
|
||||
setAudioStatus("Error: " + err);
|
||||
},
|
||||
function(status) {
|
||||
console.log("playAudio():Audio Status: "+status);
|
||||
setAudioStatus(Media.MEDIA_MSG[status]);
|
||||
|
||||
// If stopped, then stop getting current position
|
||||
if (Media.MEDIA_STOPPED == status) {
|
||||
clearInterval(media1Timer);
|
||||
media1Timer = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
audioSrc = src;
|
||||
document.getElementById('audio_duration').innerHTML = "";
|
||||
// Play audio
|
||||
media1.play();
|
||||
if (media1Timer == null && media1.getCurrentPosition) {
|
||||
media1Timer = setInterval(
|
||||
function() {
|
||||
media1.getCurrentPosition(
|
||||
function(position) {
|
||||
console.log("Pos="+position);
|
||||
if (position > -1) {
|
||||
setAudioPosition(position+" sec");
|
||||
}
|
||||
},
|
||||
function(e) {
|
||||
console.log("Error getting pos="+e);
|
||||
setAudioPosition("Error: "+e);
|
||||
}
|
||||
);
|
||||
},
|
||||
1000
|
||||
);
|
||||
}
|
||||
|
||||
// Get duration
|
||||
var counter = 0;
|
||||
var timerDur = setInterval(
|
||||
function() {
|
||||
counter = counter + 100;
|
||||
if (counter > 2000) {
|
||||
clearInterval(timerDur);
|
||||
}
|
||||
var dur = media1.getDuration();
|
||||
if (dur > 0) {
|
||||
clearInterval(timerDur);
|
||||
document.getElementById('audio_duration').innerHTML = dur + " sec";
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause audio playback
|
||||
*/
|
||||
function pauseAudio() {
|
||||
console.log("pauseAudio()");
|
||||
if (media1) {
|
||||
media1.pause();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop audio
|
||||
*/
|
||||
function stopAudio() {
|
||||
console.log("stopAudio()");
|
||||
if (media1) {
|
||||
media1.stop();
|
||||
}
|
||||
clearInterval(media1Timer);
|
||||
media1Timer = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set audio status
|
||||
*/
|
||||
var setAudioStatus = function(status) {
|
||||
document.getElementById('audio_status').innerHTML = status;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set audio position
|
||||
*/
|
||||
var setAudioPosition = function(position) {
|
||||
document.getElementById('audio_position').innerHTML = position;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Audio recorder
|
||||
//-------------------------------------------------------------------------
|
||||
var mediaRec = null;
|
||||
var recTime = 0;
|
||||
|
||||
/**
|
||||
* Record audio
|
||||
*/
|
||||
function recordAudio() {
|
||||
console.log("recordAudio()");
|
||||
console.log(" -- media="+mediaRec);
|
||||
if (mediaRec == null) {
|
||||
|
||||
var src = recordSrc;
|
||||
mediaRec = new Media(src,
|
||||
function() {
|
||||
console.log("recordAudio():Audio Success");
|
||||
},
|
||||
function(err) {
|
||||
console.log("recordAudio():Audio Error: "+err);
|
||||
setAudioStatus("Error: " + err);
|
||||
},
|
||||
function(status) {
|
||||
console.log("recordAudio():Audio Status: "+status);
|
||||
setAudioStatus(Media.MEDIA_MSG[status]);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
navigator.notification.beep(1);
|
||||
|
||||
// Record audio
|
||||
mediaRec.startRecord();
|
||||
|
||||
// Stop recording after 10 sec
|
||||
recTime = 0;
|
||||
var recInterval = setInterval(function() {
|
||||
recTime = recTime + 1;
|
||||
setAudioPosition(recTime+" sec");
|
||||
if (recTime >= 10) {
|
||||
clearInterval(recInterval);
|
||||
if (mediaRec.stopAudioRecord){
|
||||
mediaRec.stopAudioRecord();
|
||||
} else {
|
||||
mediaRec.stopRecord();
|
||||
}
|
||||
console.log("recordAudio(): stop");
|
||||
navigator.notification.beep(1);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Play back recorded audio
|
||||
*/
|
||||
function playRecording() {
|
||||
playAudio(recordSrc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to create a file for iOS recording
|
||||
*/
|
||||
function getRecordSrc() {
|
||||
var fsFail = function(error) {
|
||||
console.log("error creating file for iOS recording");
|
||||
};
|
||||
var gotFile = function(file) {
|
||||
recordSrc = file.fullPath;
|
||||
//console.log("recording Src: " + recordSrc);
|
||||
};
|
||||
var gotFS = function(fileSystem) {
|
||||
fileSystem.root.getFile("iOSRecording.wav", {create: true}, gotFile, fsFail);
|
||||
};
|
||||
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fsFail);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
if (device.platform.indexOf("iPhone") !=-1 || device.platform.indexOf("iPad") !=-1)
|
||||
{
|
||||
getRecordSrc();
|
||||
}
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Audio</h1>
|
||||
<div id="info">
|
||||
<table width="100%">
|
||||
<tr><td><b>Status:</b></td><td id="audio_status"> </td></tr>
|
||||
<tr><td><b>Duration:</b></td><td id="audio_duration"></td></tr>
|
||||
<tr><td><b>Position:</b></td><td id="audio_position"></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="playAudio();">Play/Unpause Audio</a>
|
||||
<a href="javascript:" class="btn large" onclick="pauseAudio();">Pause Playing Audio</a>
|
||||
<a href="javascript:" class="btn large" onclick="stopAudio();">Stop Playing Audio</a>
|
||||
<a href="javascript:" class="btn large" onclick="recordAudio();">Record Audio for 10 sec</a>
|
||||
<a href="javascript:" class="btn large" onclick="playRecording();">Play/Unpause Recording</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,62 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes, initial-scale=1.0;" />
|
||||
|
||||
<title>PhoneGap API Spec</title>
|
||||
|
||||
<!-- Load QUnit -->
|
||||
<link rel="stylesheet" type="text/css" href="qunit.css" />
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
|
||||
<!-- Source -->
|
||||
<script type="text/javascript" src="../phonegap.js"></script>
|
||||
|
||||
<!-- Load Test Runner -->
|
||||
<script type="text/javascript" src="test-runner.js"></script>
|
||||
|
||||
<!-- Tests -->
|
||||
<script type="text/javascript" src="tests/accelerometer.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/battery.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/capture.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/compass.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/contacts.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/camera.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/device.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/file.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/geolocation.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/network.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/notification.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/orientation.tests.js"></script>
|
||||
<script type="text/javascript" src="tests/storage.tests.js"></script>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('deviceready', function() {
|
||||
console.log('running tests');
|
||||
var tests = new Tests();
|
||||
|
||||
// Each group of tests are declared as a function in the object `Tests`.
|
||||
// A group of tests are identified by a name that contains the word 'Tests'.
|
||||
//
|
||||
// Load each group of tests into QUnit
|
||||
for (var t in tests) {
|
||||
if (t.indexOf('Tests') > -1) {
|
||||
tests[t]();
|
||||
}
|
||||
}
|
||||
|
||||
// Start the QUnit test suite
|
||||
QUnit.start();
|
||||
}, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">PhoneGap API Spec</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">
|
||||
<!-- Populated by tests -->
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,215 +0,0 @@
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699a4;
|
||||
background-color: #0d3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
|
||||
border-radius: 15px 15px 0 0;
|
||||
-moz-border-radius: 15px 15px 0 0;
|
||||
-webkit-border-top-right-radius: 15px;
|
||||
-webkit-border-top-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #c2ccd1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 0 0.5em 2em;
|
||||
color: #5E740B;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
background-color: #2b81af;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom: 1px solid #fff;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #c2ccd1;
|
||||
text-decoration: none;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests ol {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
|
||||
box-shadow: inset 0px 2px 13px #999;
|
||||
-moz-box-shadow: inset 0px 2px 13px #999;
|
||||
-webkit-box-shadow: inset 0px 2px 13px #999;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: .2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 .5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #e0f2be;
|
||||
color: #374e0c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #ffcaca;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: black; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
margin: 0.5em;
|
||||
padding: 0.4em 0.5em 0.4em 0.5em;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #5E740B;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #EE5757;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 15px 15px;
|
||||
-moz-border-radius: 0 0 15px 15px;
|
||||
-webkit-border-bottom-right-radius: 15px;
|
||||
-webkit-border-bottom-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: green; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +0,0 @@
|
||||
// Prevent QUnit from running when the DOM load event fires
|
||||
QUnit.config.autostart = false;
|
||||
sessionStorage.clear();
|
||||
|
||||
// Timeout is 2 seconds to allow physical devices enough
|
||||
// time to query the response. This is important for some
|
||||
// Android devices.
|
||||
var Tests = function() {};
|
||||
Tests.TEST_TIMEOUT = 2000;
|
@ -1,55 +0,0 @@
|
||||
Tests.prototype.AccelerometerTests = function() {
|
||||
module('Accelerometer (navigator.accelerometer)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.accelerometer != null, "navigator.accelerometer should not be null.");
|
||||
});
|
||||
test("should contain a getCurrentAcceleration function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.accelerometer.getCurrentAcceleration != 'undefined' && navigator.accelerometer.getCurrentAcceleration != null, "navigator.accelerometer.getCurrentAcceleration should not be null.");
|
||||
ok(typeof navigator.accelerometer.getCurrentAcceleration == 'function', "navigator.accelerometer.getCurrentAcceleration should be a function.");
|
||||
});
|
||||
test("getCurrentAcceleration success callback should be called with an Acceleration object", function() {
|
||||
expect(7);
|
||||
QUnit.stop(Tests.TEST_TIMEOUT);
|
||||
var win = function(a) {
|
||||
ok(typeof a == 'object', "Acceleration object returned in getCurrentAcceleration success callback should be of type 'object'.");
|
||||
ok(a.x != null, "Acceleration object returned in getCurrentAcceleration success callback should have an 'x' property.");
|
||||
ok(typeof a.x == 'number', "Acceleration object's 'x' property returned in getCurrentAcceleration success callback should be of type 'number'.");
|
||||
ok(a.y != null, "Acceleration object returned in getCurrentAcceleration success callback should have a 'y' property.");
|
||||
ok(typeof a.y == 'number', "Acceleration object's 'y' property returned in getCurrentAcceleration success callback should be of type 'number'.");
|
||||
ok(a.z != null, "Acceleration object returned in getCurrentAcceleration success callback should have a 'z' property.");
|
||||
ok(typeof a.z == 'number', "Acceleration object's 'z' property returned in getCurrentAcceleration success callback should be of type 'number'.");
|
||||
start();
|
||||
};
|
||||
var fail = function() { start(); };
|
||||
navigator.accelerometer.getCurrentAcceleration(win, fail);
|
||||
});
|
||||
test("should contain a watchAcceleration function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.accelerometer.watchAcceleration != 'undefined' && navigator.accelerometer.watchAcceleration != null, "navigator.accelerometer.watchAcceleration should not be null.");
|
||||
ok(typeof navigator.accelerometer.watchAcceleration == 'function', "navigator.accelerometer.watchAcceleration should be a function.");
|
||||
});
|
||||
test("should contain a clearWatch function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.accelerometer.clearWatch != 'undefined' && navigator.accelerometer.clearWatch != null, "navigator.accelerometer.clearWatch should not be null.");
|
||||
ok(typeof navigator.accelerometer.clearWatch == 'function', "navigator.accelerometer.clearWatch should be a function!");
|
||||
});
|
||||
module('Acceleration model');
|
||||
test("should be able to define a new Acceleration object with x, y, z and timestamp properties.", function () {
|
||||
expect(9);
|
||||
var x = 1;
|
||||
var y = 2;
|
||||
var z = 3;
|
||||
var a = new Acceleration(x, y, z);
|
||||
ok(a != null, "new Acceleration object should not be null.");
|
||||
ok(typeof a == 'object', "new Acceleration object should be of type 'object'.");
|
||||
ok(a.x != null, "new Acceleration object should have an 'x' property.");
|
||||
equals(a.x, x, "new Acceleration object should have 'x' property equal to first parameter passed in Acceleration constructor.");
|
||||
ok(a.y != null, "new Acceleration object should have a 'y' property.");
|
||||
equals(a.y, y, "new Acceleration object should have 'y' property equal to second parameter passed in Acceleration constructor.");
|
||||
ok(a.z != null, "new Acceleration object should have a 'z' property.");
|
||||
equals(a.z, z, "new Acceleration object should have 'z' property equal to third parameter passed in Acceleration constructor.");
|
||||
ok(a.timestamp != null, "new Acceleration object should have a 'timestamp' property.");
|
||||
});
|
||||
};
|
@ -1,18 +0,0 @@
|
||||
Tests.prototype.BatteryTests = function() {
|
||||
module('Battery (navigator.battery)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.battery != null, "navigator.battery should not be null.");
|
||||
});
|
||||
/**
|
||||
* Tests add for Battery Status API spec
|
||||
* http://www.w3.org/TR/2011/WD-battery-status-20111129/
|
||||
*/
|
||||
test("should have properties", function() {
|
||||
expect(4);
|
||||
ok(typeof navigator.battery.charging != 'undefined' && navigator.battery.charging != null, "navigator.battery.charging should be a boolean value.");
|
||||
ok(typeof navigator.battery.chargingTime != 'undefined' && navigator.battery.chargingTime != null, "navigator.battery.chargingTime should be a double value.");
|
||||
ok(typeof navigator.battery.level != 'undefined' && navigator.battery.level != null, "navigator.battery.level should be a double value.");
|
||||
ok(typeof navigator.battery.dischargingTime != 'undefined' && navigator.battery.dischargingTime != null, "navigator.battery.dischargingTime should be a double value.");
|
||||
});
|
||||
};
|
@ -1,40 +0,0 @@
|
||||
Tests.prototype.CameraTests = function() {
|
||||
module('Camera (navigator.camera)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.camera !== null, "navigator.camera should not be null.");
|
||||
});
|
||||
test("should contain a getPicture function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.camera.getPicture != 'undefined' && navigator.camera.getPicture !== null, "navigator.camera.getPicture should not be null.");
|
||||
ok(typeof navigator.camera.getPicture == 'function', "navigator.camera.getPicture should be a function.");
|
||||
});
|
||||
|
||||
module('Camera Constants (window.Camera)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(window.Camera !== null, "window.Camera should not be null.");
|
||||
});
|
||||
test("should contain two DestinationType constants", function() {
|
||||
expect(2);
|
||||
equals(Camera.DestinationType.DATA_URL, 0, "DestinationType.DATA_URL should equal to 0");
|
||||
equals(Camera.DestinationType.FILE_URI, 1, "DestinationType.DATA_URL should equal to 1");
|
||||
});
|
||||
test("should contain two EncodingType constants", function() {
|
||||
expect(2);
|
||||
equals(Camera.EncodingType.JPEG, 0, "EncodingType.JPEG should equal to 0");
|
||||
equals(Camera.EncodingType.PNG, 1, "EncodingType.PNG should equal to 1");
|
||||
});
|
||||
test("should contain three MediaType constants", function() {
|
||||
expect(3);
|
||||
equals(Camera.MediaType.PICTURE, 0, 'MediaType.PICTURE should equal to 0');
|
||||
equals(Camera.MediaType.VIDEO, 1, 'MediaType.VIDEO should equal to 1');
|
||||
equals(Camera.MediaType.ALLMEDIA, 2, 'MediaType.ALLMEDIA should equal to 2');
|
||||
});
|
||||
test("should contain three PictureSourceType constants", function() {
|
||||
expect(3);
|
||||
equals(Camera.PictureSourceType.PHOTOLIBRARY, 0, 'PictureSourceType.PHOTOLIBRARY should equal to 0');
|
||||
equals(Camera.PictureSourceType.CAMERA, 1, 'PictureSourceType.CAMERA should equal to 1');
|
||||
equals(Camera.PictureSourceType.SAVEDPHOTOALBUM, 2, 'PictureSourceType.SAVEDPHOTOALBUM should equal to 2');
|
||||
});
|
||||
};
|
@ -1,97 +0,0 @@
|
||||
Tests.prototype.CaptureTests = function() {
|
||||
module('Capture (navigator.device.capture)');
|
||||
test("should exist", function() {
|
||||
expect(2);
|
||||
ok(navigator.device !== null, "navigator.device should not be null.");
|
||||
ok(navigator.device.capture !== null, "navigator.device.capture should not be null.");
|
||||
});
|
||||
test("should have the correct properties ", function() {
|
||||
expect(3);
|
||||
ok(typeof navigator.device.capture.supportedAudioModes != 'undefined' && navigator.device.capture.supportedAudioModes !== null , "there should be a supported audio modes property");
|
||||
ok(typeof navigator.device.capture.supportedImageModes != 'undefined' && navigator.device.capture.supportedImageModes !== null , "there should be a supported image modes property");
|
||||
ok(typeof navigator.device.capture.supportedVideoModes != 'undefined' && navigator.device.capture.supportedVideoModes !== null , "there should be a supported video modes property");
|
||||
});
|
||||
test("should contain a captureAudio function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.device.capture.captureAudio != 'undefined' && navigator.device.capture.captureAudio !== null, "navigator.device.capture.captureAudio should not be null.");
|
||||
ok(typeof navigator.device.capture.captureAudio == 'function', "navigator.device.capture.captureAudio should be a function.");
|
||||
});
|
||||
test("should contain a captureImage function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.device.capture.captureImage != 'undefined' && navigator.device.capture.captureImage !== null, "navigator.device.capture.captureImage should not be null.");
|
||||
ok(typeof navigator.device.capture.captureImage == 'function', "navigator.device.capture.captureImage should be a function.");
|
||||
});
|
||||
test("should contain a captureVideo function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.device.capture.captureVideo != 'undefined' && navigator.device.capture.captureVideo !== null, "navigator.device.capture.captureVideo should not be null.");
|
||||
ok(typeof navigator.device.capture.captureVideo == 'function', "navigator.device.capture.captureVideo should be a function.");
|
||||
});
|
||||
|
||||
module('CaptureAudioOptions');
|
||||
test("CaptureAudioOptions constructor should exist", function() {
|
||||
expect(4);
|
||||
var options = new CaptureAudioOptions();
|
||||
ok(options !== null, "CaptureAudioOptions object should not be null.");
|
||||
ok(typeof options.limit !== 'undefined', "CaptureAudioOptions object should have a 'limit' property.");
|
||||
ok(typeof options.duration !== 'undefined', "CaptureAudioOptions object should have a 'duration' property.");
|
||||
ok(typeof options.mode !== 'undefined', "CaptureAudioOptions object should have a 'mode' property.");
|
||||
});
|
||||
|
||||
module('CaptureImageOptions');
|
||||
test("CaptureImageOptions constructor should exist", function() {
|
||||
expect(3);
|
||||
var options = new CaptureImageOptions();
|
||||
ok(options !== null, "CaptureImageOptions object should not be null.");
|
||||
ok(typeof options.limit !== 'undefined', "CaptureImageOptions object should have a 'limit' property.");
|
||||
ok(typeof options.mode !== 'undefined', "CaptureImageOptions object should have a 'mode' property.");
|
||||
});
|
||||
|
||||
module('CaptureVideoOptions');
|
||||
test("CaptureVideoOptions constructor should exist", function() {
|
||||
expect(4);
|
||||
var options = new CaptureVideoOptions();
|
||||
ok(options !== null, "CaptureVideoOptions object should not be null.");
|
||||
ok(typeof options.limit !== 'undefined', "CaptureVideoOptions object should have a 'limit' property.");
|
||||
ok(typeof options.duration !== 'undefined', "CaptureVideoOptions object should have a 'duration' property.");
|
||||
ok(typeof options.mode !== 'undefined', "CaptureVideoOptions object should have a 'mode' property.");
|
||||
});
|
||||
|
||||
module('CaptureError interface');
|
||||
test("CaptureError constants should be defined", function() {
|
||||
expect(4);
|
||||
equal(CaptureError.CAPTURE_INTERNAL_ERR, 0, "CaptureError.CAPTURE_INTERNAL_ERR should be defined");
|
||||
equal(CaptureError.CAPTURE_APPLICATION_BUSY, 1, "CaptureError.CAPTURE_APPLICATION_BUSY should be defined");
|
||||
equal(CaptureError.CAPTURE_INVALID_ARGUMENT, 2, "CaptureError.CAPTURE_INVALID_ARGUMENT should be defined");
|
||||
equal(CaptureError.CAPTURE_NO_MEDIA_FILES, 3, "CaptureError.CAPTURE_NO_MEDIA_FILES should be defined");
|
||||
});
|
||||
test("CaptureError properties should exist", function() {
|
||||
expect(2);
|
||||
var error = new CaptureError();
|
||||
ok(error !== null, "CaptureError object should not be null.");
|
||||
ok(typeof error.code !== 'undefined', "CaptureError object should have a 'code' property.");
|
||||
});
|
||||
|
||||
module('MediaFileData');
|
||||
test("MediaFileData constructor should exist", function() {
|
||||
expect(6);
|
||||
var fileData = new MediaFileData();
|
||||
ok(fileData !== null, "MediaFileData object should not be null.");
|
||||
ok(typeof fileData.bitrate !== 'undefined', "MediaFileData object should have a 'bitrate' property.");
|
||||
ok(typeof fileData.codecs !== 'undefined', "MediaFileData object should have a 'codecs' property.");
|
||||
ok(typeof fileData.duration !== 'undefined', "MediaFileData object should have a 'duration' property.");
|
||||
ok(typeof fileData.height !== 'undefined', "MediaFileData object should have a 'height' property.");
|
||||
ok(typeof fileData.width !== 'undefined', "MediaFileData object should have a 'width' property.");
|
||||
});
|
||||
|
||||
module('MediaFile');
|
||||
test("MediaFile constructor should exist", function() {
|
||||
expect(6);
|
||||
var fileData = new MediaFileData();
|
||||
ok(fileData !== null, "MediaFileData object should not be null.");
|
||||
ok(typeof fileData.name !== 'undefined', "MediaFile object should have a 'name' property.");
|
||||
ok(typeof fileData.fullPath !== 'undefined', "MediaFile object should have a 'fullPath' property.");
|
||||
ok(typeof fileData.type !== 'undefined', "MediaFile object should have a 'type' property.");
|
||||
ok(typeof fileData.lastModifiedDate !== 'undefined', "MediaFile object should have a 'lastModifiedDate' property.");
|
||||
ok(typeof fileData.size !== 'undefined', "MediaFile object should have a 'size' property.");
|
||||
});
|
||||
};
|
@ -1,62 +0,0 @@
|
||||
Tests.prototype.CompassTests = function() {
|
||||
module('Compass (navigator.compass)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.compass !== null, "navigator.compass should not be null.");
|
||||
});
|
||||
test("should contain a getCurrentHeading function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.compass.getCurrentHeading != 'undefined' && navigator.compass.getCurrentHeading !== null, "navigator.compass.getCurrentHeading should not be null.");
|
||||
ok(typeof navigator.compass.getCurrentHeading == 'function', "navigator.compass.getCurrentHeading should be a function.");
|
||||
});
|
||||
test("getCurrentHeading success callback should be called with a Heading object", function() {
|
||||
expect(9);
|
||||
QUnit.stop(Tests.TEST_TIMEOUT);
|
||||
var win = function(a) {
|
||||
ok(typeof a == 'object', "Heading object returned in getCurrentHeading success callback should be of type 'object'.");
|
||||
ok(a.magneticHeading !== null, "Heading object returned in getCurrentHeading success callback should have an 'magneticHeading' property.");
|
||||
ok(typeof a.magneticHeading == 'number', "Heading object's 'magneticHeading' property returned in getCurrentHeading success callback should be of type 'number'.");
|
||||
ok(a.trueHeading !== null, "Heading object returned in getCurrentHeading success callback should have a 'trueHeading' property.");
|
||||
ok(typeof a.trueHeading == 'number', "Heading object's 'trueHeading' property returned in getCurrentHeading success callback should be of type 'number'.");
|
||||
ok(a.headingAccuracy !== null, "Heading object returned in getCurrentHeading success callback should have a 'headingAccuracy' property.");
|
||||
ok(typeof a.headingAccuracy == 'number', "Heading object's 'headingAccuracy' property returned in getCurrentHeading success callback should be of type 'number'.");
|
||||
ok(a.timestamp !== null, "Heading object returned in getCurrentHeading success callback should have a 'timestamp' property.");
|
||||
ok(a.timestamp instanceof Date, "Heading object's 'timestamp' property returned in getCurrentHeading success callback should be an instance of Date.");
|
||||
QUnit.start();
|
||||
};
|
||||
var fail = function() { QUnit.start(); };
|
||||
navigator.compass.getCurrentHeading(win, fail);
|
||||
});
|
||||
test("should contain a watchHeading function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.compass.watchHeading != 'undefined' && navigator.compass.watchHeading !== null, "navigator.compass.watchHeading should not be null.");
|
||||
ok(typeof navigator.compass.watchHeading == 'function', "navigator.compass.watchHeading should be a function.");
|
||||
});
|
||||
test("should contain a clearWatch function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.compass.clearWatch != 'undefined' && navigator.compass.clearWatch !== null, "navigator.compass.clearWatch should not be null.");
|
||||
ok(typeof navigator.compass.clearWatch == 'function', "navigator.compass.clearWatch should be a function!");
|
||||
});
|
||||
|
||||
module('Compass Constants (window.CompassError)');
|
||||
test("CompassError globals should exist", function() {
|
||||
expect(3);
|
||||
ok(window.CompassError !== null, 'window.CompassError should not be null');
|
||||
equals(window.CompassError.COMPASS_INTERNAL_ERR, 0, 'window.CompassError.COMPASS_INTERNAL_ERR should be 0');
|
||||
equals(window.CompassError.COMPASS_NOT_SUPPORTED, 20, 'window.CompassError.COMPASS_NOT_SUPPORTED should be 20');
|
||||
});
|
||||
|
||||
module('Compass Heading model (CompassHeading)');
|
||||
test("CompassHeading function should exist", function() {
|
||||
expect(1);
|
||||
ok(typeof CompassHeading != 'undefined' && CompassHeading !== null, 'CompassHeading should not be null');
|
||||
});
|
||||
test("Creating a new CompassHeading instance", function() {
|
||||
expect(4);
|
||||
var h = new CompassHeading();
|
||||
equals(h.magneticHeading, null, "CompassHeading instance should have null magneticHeading property by default");
|
||||
equals(h.trueHeading, null, "CompassHeading instance should have null trueHeading property by default");
|
||||
equals(h.headingAccuracy, null, "CompassHeading instance should have null headingAccuracy property by default");
|
||||
ok(h.timestamp !== null, "CompassHeading instance should have timestamp that is not null by default");
|
||||
});
|
||||
};
|
@ -1,219 +0,0 @@
|
||||
Tests.prototype.ContactsTests = function() {
|
||||
module("Contacts (navigator.contacts)");
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.contacts != null, "navigator.contacts should not be null.");
|
||||
});
|
||||
test("should contain a find function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.contacts.find != 'undefined' && navigator.contacts.find != null, "navigator.contacts.find should not be null.");
|
||||
ok(typeof navigator.contacts.find == 'function', "navigator.contacts.find should be a function.");
|
||||
});
|
||||
test("contacts.find success callback should be called with an array", function() {
|
||||
expect(2);
|
||||
QUnit.stop(Tests.TEST_TIMEOUT);
|
||||
var win = function(result) {
|
||||
ok(typeof result == 'object', "Object returned in contacts.find success callback is of type 'object' (actually array).");
|
||||
ok(typeof result.length == 'number', "Object returned in contacts.find success callback has a length property which is numerical.");
|
||||
QUnit.start();
|
||||
};
|
||||
var fail = function() { QUnit.start(); };
|
||||
var obj = new ContactFindOptions();
|
||||
obj.filter="";
|
||||
obj.multiple=true;
|
||||
navigator.contacts.find(["displayName", "name", "phoneNumbers", "emails"], win, fail, obj);
|
||||
});
|
||||
test("contacts.find success callback should not be null", function() {
|
||||
expect(1);
|
||||
var fail = function() {};
|
||||
var obj = new ContactFindOptions();
|
||||
obj.filter="";
|
||||
obj.multiple=true;
|
||||
try {
|
||||
navigator.contacts.find(["displayName", "name", "emails", "phoneNumbers"], null, fail, obj);
|
||||
} catch(e) {
|
||||
ok(true, "Trying to find with a null success call back should throw TypeError.");
|
||||
}
|
||||
});
|
||||
test("contacts.find error callback should be called when no fields are specified", function() {
|
||||
expect(2);
|
||||
QUnit.stop(Tests.TEST_TIMEOUT);
|
||||
var win = function(result) {
|
||||
QUnit.start();
|
||||
};
|
||||
var fail = function(result) {
|
||||
ok(typeof result == 'object', "Object returned in contact.find failure callback is of type 'object' (actually ContactError).");
|
||||
ok(result.code == ContactError.INVALID_ARGUMENT_ERROR, "Object returned in contacts.find failure callback has a code property which equal to ContactError.INVALID_ARGUMENT_ERROR.");
|
||||
QUnit.start();
|
||||
};
|
||||
var obj = new ContactFindOptions();
|
||||
obj.filter="";
|
||||
obj.multiple=true;
|
||||
navigator.contacts.find([], win, fail, obj);
|
||||
});
|
||||
test("should contain a create function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.contacts.create != 'undefined' && navigator.contacts.create != null, "navigator.contacts.create should not be null.");
|
||||
ok(typeof navigator.contacts.create == 'function', "navigator.contacts.create should be a function.");
|
||||
});
|
||||
test("contacts.create should return a Contact object", function() {
|
||||
expect(9);
|
||||
var obj = navigator.contacts.create({"displayName": "test name", "gender": "male", "note": "my note", "name": {"formatted": "Mr. Test Name"}, "emails": [{"value": "here@there.com"}, {"value": "there@here.com"}]});
|
||||
ok(obj != 'undefined' && obj != null, "navigator.contacts.create should return a Contact object.");
|
||||
ok(obj.displayName == 'test name', "Contact should contain a displayName property.");
|
||||
ok(obj.gender == 'male', "Contact should contain a gender property.");
|
||||
ok(obj.note == 'my note', "Contact should contain a note property.");
|
||||
ok(obj.name.formatted == 'Mr. Test Name', "Contact should contain a name.formatted property.");
|
||||
ok(obj.emails.length == 2, "Contact should contain and array of emails with 2 entries");
|
||||
ok(obj.emails[0].value == 'here@there.com', "Contact.emails[1] should contain a value.");
|
||||
ok(obj.emails[1].value == 'there@here.com', "Contact.emails[2] should contain a value.");
|
||||
ok(obj.birthday == null, "Contact object should not contain a birthday property.");
|
||||
});
|
||||
module("Contact model");
|
||||
test("should be able to define a Contact object", function() {
|
||||
expect(15);
|
||||
var contact = new Contact("a", "b", new ContactName("a", "b", "c", "d", "e", "f"), "c", [], [], [], [], [], "f", "i",
|
||||
[], [], []);
|
||||
ok(contact != null, "new Contact() should not be null.");
|
||||
ok(typeof contact.id != 'undefined' && contact.id != null && contact.id == "a", "new Contact() should include a 'id' property.");
|
||||
ok(typeof contact.displayName != 'undefined' && contact.displayName != null && contact.displayName == "b", "new Contact() should include a 'displayName' property.");
|
||||
ok(typeof contact.name != 'undefined' && contact.name != null && contact.name.formatted == "a", "new Contact() should include a 'name' property.");
|
||||
ok(typeof contact.nickname != 'undefined' && contact.nickname != null && contact.nickname == "c", "new Contact() should include a 'nickname' property.");
|
||||
ok(typeof contact.phoneNumbers != 'undefined' && contact.phoneNumbers != null, "new Contact() should include a 'phoneNumbers' property.");
|
||||
ok(typeof contact.emails != 'undefined' && contact.emails != null, "new Contact() should include a 'emails' property.");
|
||||
ok(typeof contact.addresses != 'undefined' && contact.addresses != null, "new Contact() should include a 'addresses' property.");
|
||||
ok(typeof contact.ims != 'undefined' && contact.ims != null, "new Contact() should include a 'ims' property.");
|
||||
ok(typeof contact.organizations != 'undefined' && contact.organizations != null, "new Contact() should include a 'organizations' property.");
|
||||
ok(typeof contact.birthday != 'undefined' && contact.birthday != null && contact.birthday == "f", "new Contact() should include a 'birthday' property.");
|
||||
ok(typeof contact.note != 'undefined' && contact.note != null && contact.note == "i", "new Contact() should include a 'note' property.");
|
||||
ok(typeof contact.photos != 'undefined' && contact.photos != null, "new Contact() should include a 'photos' property.");
|
||||
ok(typeof contact.categories != 'undefined' && contact.categories != null, "new Contact() should include a 'categories' property.");
|
||||
ok(typeof contact.urls != 'undefined' && contact.urls != null, "new Contact() should include a 'urls' property.");
|
||||
});
|
||||
test("should be able to define a ContactName object", function() {
|
||||
expect(7);
|
||||
var contactName = new ContactName("Dr. First Last Jr.", "Last", "First", "Middle", "Dr.", "Jr.");
|
||||
ok(contactName != null, "new ContactName() should not be null.");
|
||||
ok(typeof contactName.formatted != 'undefined' && contactName.formatted != null && contactName.formatted == "Dr. First Last Jr.", "new ContactName() should include a 'formatted' property.");
|
||||
ok(typeof contactName.familyName != 'undefined' && contactName.familyName != null && contactName.familyName == "Last", "new ContactName() should include a 'familyName' property.");
|
||||
ok(typeof contactName.givenName != 'undefined' && contactName.givenName != null && contactName.givenName == "First", "new ContactName() should include a 'givenName' property.");
|
||||
ok(typeof contactName.middleName != 'undefined' && contactName.middleName != null && contactName.middleName == "Middle", "new ContactName() should include a 'middleName' property.");
|
||||
ok(typeof contactName.honorificPrefix != 'undefined' && contactName.honorificPrefix != null && contactName.honorificPrefix == "Dr.", "new ContactName() should include a 'honorificPrefix' property.");
|
||||
ok(typeof contactName.honorificSuffix != 'undefined' && contactName.honorificSuffix != null && contactName.honorificSuffix == "Jr.", "new ContactName() should include a 'honorificSuffix' property.");
|
||||
});
|
||||
test("should be able to define a ContactField object", function() {
|
||||
expect(4);
|
||||
var contactField = new ContactField("home", "8005551212", true);
|
||||
ok(contactField != null, "new ContactField() should not be null.");
|
||||
ok(typeof contactField.type != 'undefined' && contactField.type != null && contactField.type == "home", "new ContactField() should include a 'type' property.");
|
||||
ok(typeof contactField.value != 'undefined' && contactField.value != null && contactField.value == "8005551212", "new ContactField() should include a 'value' property.");
|
||||
ok(typeof contactField.pref != 'undefined' && contactField.pref != null && contactField.pref == true, "new ContactField() should include a 'pref' property.");
|
||||
});
|
||||
test("should be able to define a ContactAddress object", function() {
|
||||
expect(9);
|
||||
var contactAddress = new ContactAddress(true, "home", "a","b","c","d","e","f");
|
||||
ok(contactAddress != null, "new ContactAddress() should not be null.");
|
||||
ok(typeof contactAddress.pref != 'undefined' && contactAddress.pref != null && contactAddress.pref == true, "new ContactAddress() should include a 'pref' property.");
|
||||
ok(typeof contactAddress.type != 'undefined' && contactAddress.type != null && contactAddress.type == "home", "new ContactAddress() should include a 'type' property.");
|
||||
ok(typeof contactAddress.formatted != 'undefined' && contactAddress.formatted != null && contactAddress.formatted == "a", "new ContactAddress() should include a 'formatted' property.");
|
||||
ok(typeof contactAddress.streetAddress != 'undefined' && contactAddress.streetAddress != null && contactAddress.streetAddress == "b", "new ContactAddress() should include a 'streetAddress' property.");
|
||||
ok(typeof contactAddress.locality != 'undefined' && contactAddress.locality != null && contactAddress.locality == "c", "new ContactAddress() should include a 'locality' property.");
|
||||
ok(typeof contactAddress.region != 'undefined' && contactAddress.region != null && contactAddress.region == "d", "new ContactAddress() should include a 'region' property.");
|
||||
ok(typeof contactAddress.postalCode != 'undefined' && contactAddress.postalCode != null && contactAddress.postalCode == "e", "new ContactAddress() should include a 'postalCode' property.");
|
||||
ok(typeof contactAddress.country != 'undefined' && contactAddress.country != null && contactAddress.country == "f", "new ContactAddress() should include a 'country' property.");
|
||||
});
|
||||
test("should be able to define a ContactOrganization object", function() {
|
||||
expect(6);
|
||||
var contactOrg = new ContactOrganization(true, "home", "a","b","c","d","e","f","g");
|
||||
ok(contactOrg != null, "new ContactOrganization() should not be null.");
|
||||
ok(typeof contactOrg.pref != 'undefined' && contactOrg.pref != null && contactOrg.pref == true, "new ContactOrganization() should include a 'pref' property.");
|
||||
ok(typeof contactOrg.type != 'undefined' && contactOrg.type != null && contactOrg.type == "home", "new ContactOrganization() should include a 'type' property.");
|
||||
ok(typeof contactOrg.name != 'undefined' && contactOrg.name != null && contactOrg.name == "a", "new ContactOrganization() should include a 'name' property.");
|
||||
ok(typeof contactOrg.department != 'undefined' && contactOrg.department != null && contactOrg.department == "b", "new ContactOrganization() should include a 'department' property.");
|
||||
ok(typeof contactOrg.title != 'undefined' && contactOrg.title != null && contactOrg.title == "c", "new ContactOrganization() should include a 'title' property.");
|
||||
});
|
||||
test("should be able to define a ContactFindOptions object", function() {
|
||||
expect(3);
|
||||
var contactFindOptions = new ContactFindOptions("a", true, "b");
|
||||
ok(contactFindOptions != null, "new ContactFindOptions() should not be null.");
|
||||
ok(typeof contactFindOptions.filter != 'undefined' && contactFindOptions.filter != null && contactFindOptions.filter == "a", "new ContactFindOptions() should include a 'filter' property.");
|
||||
ok(typeof contactFindOptions.multiple != 'undefined' && contactFindOptions.multiple != null && contactFindOptions.multiple == true, "new ContactFindOptions() should include a 'multiple' property.");
|
||||
});
|
||||
module("Contact Object");
|
||||
test("should contain a clone function", function() {
|
||||
expect(2);
|
||||
var contact = new Contact();
|
||||
ok(typeof contact.clone != 'undefined' && contact.clone != null, "contact.clone should not be null.");
|
||||
ok(typeof contact.clone == 'function', "contact.clone should be a function.");
|
||||
});
|
||||
test("clone function should make deep copy of Contact Object", function() {
|
||||
expect(8);
|
||||
var contact = new Contact();
|
||||
contact.id=1;
|
||||
contact.displayName="Test Name";
|
||||
contact.nickname="Testy";
|
||||
contact.gender="male";
|
||||
contact.note="note to be cloned";
|
||||
contact.name = new ContactName("Mr. Test Name");
|
||||
|
||||
var clonedContact = contact.clone();
|
||||
|
||||
ok(contact.id == 1, "contact.id should be 1.");
|
||||
ok(clonedContact.id == null, "clonedContact.id should be null.");
|
||||
ok(clonedContact.displayName == contact.displayName, "displayName's should be equal");
|
||||
ok(clonedContact.nickname == contact.nickname, "nickname's should be equal");
|
||||
ok(clonedContact.gender == contact.gender, "gender's should be equal");
|
||||
ok(clonedContact.note == contact.note, "note's should be equal");
|
||||
ok(clonedContact.name.formatted == contact.name.formatted, "name.formatted's should be equal");
|
||||
ok(clonedContact.connected == contact.connected, "connected's should be equal (null)");
|
||||
});
|
||||
test("should contain a remove function", function() {
|
||||
expect(2);
|
||||
var contact = new Contact();
|
||||
ok(typeof contact.remove != 'undefined' && contact.remove != null, "contact.remove should not be null.");
|
||||
ok(typeof contact.remove == 'function', "contact.remove should be a function.");
|
||||
});
|
||||
test("calling remove on a contact has an id of null should return ContactError.UNKNOWN_ERROR", function() {
|
||||
QUnit.stop(Tests.TEST_TIMEOUT);
|
||||
expect(2);
|
||||
var win = function(result) {
|
||||
};
|
||||
var fail = function(result) {
|
||||
ok(typeof result == 'object', "Object returned in contact.remove failure callback is of type 'object' (actually ContactError).");
|
||||
ok(result.code == ContactError.UNKNOWN_ERROR, "Object returned in contacts.remove failure callback has a code property which equal to ContactError.UNKNOWN_ERROR.");
|
||||
QUnit.start();
|
||||
};
|
||||
var rmContact = new Contact();
|
||||
rmContact.remove(win, fail);
|
||||
});
|
||||
test("calling remove on a contact that does not exist should return ContactError.UNKNOWN_ERROR", function() {
|
||||
QUnit.stop(Tests.TEST_TIMEOUT);
|
||||
expect(2);
|
||||
var win = function(result) {
|
||||
};
|
||||
var fail = function(result) {
|
||||
ok(typeof result == 'object', "Object returned in contact.remove failure callback is of type 'object' (actually ContactError).");
|
||||
ok(result.code == ContactError.UNKNOWN_ERROR, "Object returned in contacts.remove failure callback has a code property which equal to ContactError.UNKNOWN_ERROR.");
|
||||
QUnit.start();
|
||||
};
|
||||
var contact = new Contact(99);
|
||||
contact.remove(win, fail);
|
||||
});
|
||||
test("should contain a save function", function() {
|
||||
expect(2);
|
||||
var contact = new Contact();
|
||||
ok(typeof contact.save != 'undefined' && contact.save != null, "contact.save should not be null.");
|
||||
ok(typeof contact.save == 'function', "contact.save should be a function.");
|
||||
});
|
||||
module('ContactError interface');
|
||||
test("ContactError constants should be defined", function() {
|
||||
expect(7);
|
||||
equal(ContactError.UNKNOWN_ERROR, 0, "ContactError.UNKNOWN_ERROR should be defined");
|
||||
equal(ContactError.INVALID_ARGUMENT_ERROR, 1, "ContactError.INVALID_ARGUMENT_ERROR should be defined");
|
||||
equal(ContactError.TIMEOUT_ERROR, 2, "ContactError.TIMEOUT_ERROR should be defined");
|
||||
equal(ContactError.PENDING_OPERATION_ERROR, 3, "ContactError.PENDING_OPERATION_ERROR should be defined");
|
||||
equal(ContactError.IO_ERROR, 4, "ContactError.IO_ERROR should be defined");
|
||||
equal(ContactError.NOT_SUPPORTED_ERROR, 5, "ContactError.NOT_SUPPORTED_ERROR should be defined");
|
||||
equal(ContactError.PERMISSION_DENIED_ERROR, 20, "ContactError.PERMISSION_DENIED_ERROR should be defined");
|
||||
});
|
||||
};
|
@ -1,36 +0,0 @@
|
||||
Tests.prototype.DeviceTests = function() {
|
||||
module('Device Information (window.device)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(window.device != null, "window.device should not be null.");
|
||||
});
|
||||
test("should contain a platform specification that is a string", function() {
|
||||
expect(2);
|
||||
ok(typeof window.device.platform != 'undefined' && window.device.platform != null, "window.device.platform should not be null.")
|
||||
ok((new String(window.device.platform)).length > 0, "window.device.platform should contain some sort of description.")
|
||||
});
|
||||
test("should contain a version specification that is a string", function() {
|
||||
expect(2);
|
||||
ok(typeof window.device.version != 'undefined' && window.device.version != null, "window.device.version should not be null.")
|
||||
ok((new String(window.device.version)).length > 0, "window.device.version should contain some kind of description.")
|
||||
});
|
||||
test("should contain a name specification that is a string", function() {
|
||||
expect(2);
|
||||
ok(typeof window.device.name != 'undefined' && window.device.name != null, "window.device.name should not be null.")
|
||||
ok((new String(window.device.name)).length > 0, "window.device.name should contain some kind of description.")
|
||||
});
|
||||
test("should contain a UUID specification that is a string or a number", function() {
|
||||
expect(2);
|
||||
ok(typeof window.device.uuid != 'undefined' && window.device.uuid != null, "window.device.uuid should not be null.")
|
||||
if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') {
|
||||
ok((new String(window.device.uuid)).length > 0, "window.device.uuid, as a string, should have at least one character.")
|
||||
} else {
|
||||
ok(window.device.uuid > 0, "window.device.uuid, as a number, should be greater than 0. (should it, even?)")
|
||||
}
|
||||
});
|
||||
test("should contain a phonegap specification that is a string", function() {
|
||||
expect(2);
|
||||
ok(typeof window.device.phonegap != 'undefined' && window.device.phonegap != null, "window.device.phonegap should not be null.")
|
||||
ok((new String(window.device.phonegap)).length > 0, "window.device.phonegap should contain some kind of description.")
|
||||
});
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,57 +0,0 @@
|
||||
Tests.prototype.GeoLocationTests = function() {
|
||||
module('Geolocation (navigator.geolocation)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.geolocation != null, "navigator.geolocation should not be null.");
|
||||
});
|
||||
test("should contain a getCurrentPosition function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.geolocation.getCurrentPosition != 'undefined' && navigator.geolocation.getCurrentPosition != null, "navigator.geolocation.getCurrentPosition should not be null.");
|
||||
ok(typeof navigator.geolocation.getCurrentPosition == 'function', "navigator.geolocation.getCurrentPosition should be a function.");
|
||||
});
|
||||
test("should contain a watchPosition function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.geolocation.watchPosition != 'undefined' && navigator.geolocation.watchPosition != null, "navigator.geolocation.watchPosition should not be null.");
|
||||
ok(typeof navigator.geolocation.watchPosition == 'function', "navigator.geolocation.watchPosition should be a function.");
|
||||
});
|
||||
test("should contain a clearWatch function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.geolocation.clearWatch != 'undefined' && navigator.geolocation.clearWatch != null, "navigator.geolocation.watchPosition should not be null.");
|
||||
ok(typeof navigator.geolocation.clearWatch == 'function', "navigator.geolocation.clearWatch should be a function.");
|
||||
});
|
||||
test("getCurrentPosition success callback should be called with a Position object", function() {
|
||||
expect(2);
|
||||
QUnit.stop(Tests.TEST_TIMEOUT);
|
||||
var win = function(p) {
|
||||
ok(p.coords != null, "Position object returned in getCurrentPosition success callback has a 'coords' property.");
|
||||
ok(p.timestamp != null, "Position object returned in getCurrentPosition success callback has a 'timestamp' property.");
|
||||
start();
|
||||
};
|
||||
var fail = function() { start(); };
|
||||
navigator.geolocation.getCurrentPosition(win, fail);
|
||||
});
|
||||
// TODO: Need to test error callback... how?
|
||||
// TODO: Need to test watchPosition success callback, test that makes sure clearPosition works (how to test that a timer is getting cleared?)
|
||||
// TODO: Need to test options object passed in. Members that need to be tested so far include:
|
||||
// - options.frequency: this is also labelled differently on some implementations (internval on iPhone/BlackBerry currently).
|
||||
module('Geolocation model');
|
||||
test("should be able to define a Position object with coords and timestamp properties", function() {
|
||||
expect(3);
|
||||
var pos = new Position({}, new Date());
|
||||
ok(pos != null, "new Position() should not be null.");
|
||||
ok(typeof pos.coords != 'undefined' && pos.coords != null, "new Position() should include a 'coords' property.");
|
||||
ok(typeof pos.timestamp != 'undefined' && pos.timestamp != null, "new Position() should include a 'timestamp' property.");
|
||||
});
|
||||
test("should be able to define a Coordinates object with latitude, longitude, accuracy, altitude, heading, speed and altitudeAccuracy properties", function() {
|
||||
expect(8);
|
||||
var coords = new Coordinates(1,2,3,4,5,6,7);
|
||||
ok(coords != null, "new Coordinates() should not be null.");
|
||||
ok(typeof coords.latitude != 'undefined' && coords.latitude != null, "new Coordinates() should include a 'latitude' property.");
|
||||
ok(typeof coords.longitude != 'undefined' && coords.longitude != null, "new Coordinates() should include a 'longitude' property.");
|
||||
ok(typeof coords.accuracy != 'undefined' && coords.accuracy != null, "new Coordinates() should include a 'accuracy' property.");
|
||||
ok(typeof coords.altitude != 'undefined' && coords.altitude != null, "new Coordinates() should include a 'altitude' property.");
|
||||
ok(typeof coords.heading != 'undefined' && coords.heading != null, "new Coordinates() should include a 'heading' property.");
|
||||
ok(typeof coords.speed != 'undefined' && coords.speed != null, "new Coordinates() should include a 'speed' property.");
|
||||
ok(typeof coords.altitudeAccuracy != 'undefined' && coords.altitudeAccuracy != null, "new Coordinates() should include a 'altitudeAccuracy' property.");
|
||||
});
|
||||
};
|
@ -1,31 +0,0 @@
|
||||
//
|
||||
// @TODO Update to Latest HTML5 Audio Element Spec
|
||||
// @see http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#audio
|
||||
//
|
||||
Tests.prototype.MediaTests = function() {
|
||||
module('Media (Audio)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(typeof Audio === "function" || typeof Audio === "object", "'Audio' should be defined as a function in global scope.");
|
||||
});
|
||||
test("should define constants for Media errors", function() {
|
||||
expect(5);
|
||||
ok(MediaError != null && typeof MediaError != 'undefined', "MediaError object exists in global scope.");
|
||||
equals(MediaError.MEDIA_ERR_ABORTED, 1, "MediaError.MEDIA_ERR_ABORTED is equal to 1.");
|
||||
equals(MediaError.MEDIA_ERR_NETWORK, 2, "MediaError.MEDIA_ERR_NETWORK is equal to 2.");
|
||||
equals(MediaError.MEDIA_ERR_DECODE, 3, "MediaError.MEDIA_ERR_DECODE is equal to 3.");
|
||||
equals(MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, 4, "MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED is equal to 4.");
|
||||
});
|
||||
test("should contain 'src', 'loop' and 'error' properties", function() {
|
||||
expect(7);
|
||||
var audioSrc = '/test.mp3';
|
||||
var audio = new Audio(audioSrc);
|
||||
ok(typeof audio == "object", "Instantiated 'Audio' object instance should be of type 'object.'");
|
||||
ok(audio.src != null && typeof audio.src != 'undefined', "Instantiated 'Audio' object's 'src' property should not be null or undefined.");
|
||||
ok(audio.src.indexOf(audioSrc) >= 0, "Instantiated 'Audio' object's 'src' property should match constructor parameter.");
|
||||
ok(audio.loop != null && typeof audio.loop != 'undefined', "Instantiated 'Audio' object's 'loop' property should not be null or undefined.");
|
||||
ok(audio.loop == false, "Instantiated 'Audio' object's 'loop' property should initially be false.");
|
||||
ok(typeof audio.error != 'undefined', "Instantiated 'Audio' object's 'error' property should not undefined.");
|
||||
ok(audio.error == null, "Instantiated 'Audio' object's 'error' should initially be null.");
|
||||
});
|
||||
};
|
@ -1,26 +0,0 @@
|
||||
Tests.prototype.NetworkTests = function() {
|
||||
module('Network (navigator.network)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.network != null, "navigator.network should not be null.");
|
||||
});
|
||||
module('Network Information API');
|
||||
test("connection should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.network.connection != null, "navigator.network.connection should not be null.");
|
||||
});
|
||||
test("should contain connection properties", function() {
|
||||
expect(1);
|
||||
ok(typeof navigator.network.connection.type != 'undefined', "navigator.network.connection.type is defined.");
|
||||
});
|
||||
test("should define constants for connection status", function() {
|
||||
expect(7);
|
||||
equals(Connection.UNKNOWN, "unknown", "Connection.UNKNOWN is equal to 'unknown'.");
|
||||
equals(Connection.ETHERNET, "ethernet", "Connection.ETHERNET is equal to 'ethernet'.");
|
||||
equals(Connection.WIFI, "wifi", "Connection.WIFI is equal to 'wifi'.");
|
||||
equals(Connection.CELL_2G, "2g", "Connection.CELL_2G is equal to '2g'.");
|
||||
equals(Connection.CELL_3G, "3g", "Connection.CELL_3G is equal to '3g'.");
|
||||
equals(Connection.CELL_4G, "4g", "Connection.CELL_4G is equal to '4g'.");
|
||||
equals(Connection.NONE, "none", "Connection.NONE is equal to 'none'.");
|
||||
});
|
||||
};
|
@ -1,22 +0,0 @@
|
||||
Tests.prototype.NotificationTests = function() {
|
||||
module('Notification (navigator.notification)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.notification != null, "navigator.notification should not be null.");
|
||||
});
|
||||
test("should contain a vibrate function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.notification.vibrate != 'undefined' && navigator.notification.vibrate != null, "navigator.notification.vibrate should not be null.");
|
||||
ok(typeof navigator.notification.vibrate == 'function', "navigator.notification.vibrate should be a function.");
|
||||
});
|
||||
test("should contain a beep function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.notification.beep != 'undefined' && navigator.notification.beep != null, "navigator.notification.beep should not be null.");
|
||||
ok(typeof navigator.notification.beep == 'function', "navigator.notification.beep should be a function.");
|
||||
});
|
||||
test("should contain a alert function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.notification.alert != 'undefined' && navigator.notification.alert != null, "navigator.notification.alert should not be null.");
|
||||
ok(typeof navigator.notification.alert == 'function', "navigator.notification.alert should be a function.");
|
||||
});
|
||||
};
|
@ -1,34 +0,0 @@
|
||||
Tests.prototype.OrientationTests = function() {
|
||||
module('Orientation (navigator.orientation)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.orientation != null, "navigator.orientation should not be null.");
|
||||
});
|
||||
test("should have an initially null lastPosition property", function() {
|
||||
expect(1);
|
||||
ok(typeof navigator.orientation.currentOrientation != 'undefined' && navigator.orientation.currentOrientation == null, "navigator.orientation.currentOrientation should be initially null.");
|
||||
});
|
||||
test("should contain a getCurrentOrientation function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.orientation.getCurrentOrientation != 'undefined' && navigator.orientation.getCurrentOrientation != null, "navigator.orientation.getCurrentOrientation should not be null.");
|
||||
ok(typeof navigator.orientation.getCurrentOrientation == 'function', "navigator.orientation.getCurrentOrientation should be a function.");
|
||||
});
|
||||
test("should contain a watchOrientation function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.orientation.watchOrientation != 'undefined' && navigator.orientation.watchOrientation != null, "navigator.orientation.watchOrientation should not be null.");
|
||||
ok(typeof navigator.orientation.watchOrientation == 'function', "navigator.orientation.watchOrientation should be a function.");
|
||||
});
|
||||
// TODO: add tests for DisplayOrientation constants?
|
||||
test("getCurrentOrientation success callback should be called with an Orientation enumeration", function() {
|
||||
expect(2);
|
||||
QUnit.stop(Tests.TEST_TIMEOUT);
|
||||
var win = function(orient) {
|
||||
ok(0 <= orient <= 6, "Position object returned in getCurrentPosition success callback is a valid DisplayOrientation value.");
|
||||
equals(orient, navigator.orientation.currentOrientation, "Orientation value returned in getCurrentOrientation success callback equals navigator.orientation.currentOrientation.");
|
||||
start();
|
||||
};
|
||||
var fail = function() { start(); };
|
||||
navigator.orientation.getCurrentOrientation(win, fail);
|
||||
});
|
||||
// TODO: Need to test watchPosition success callback, test that makes sure clearPosition works (how to test that a timer is getting cleared?)
|
||||
};
|
@ -1,170 +0,0 @@
|
||||
Tests.prototype.StorageTests = function()
|
||||
{
|
||||
module("Session Storage");
|
||||
test("should exist", function() {
|
||||
expect(7);
|
||||
ok(window.sessionStorage != null, "sessionStorage is defined");
|
||||
ok(typeof window.sessionStorage.length != 'undefined', "sessionStorage.length is defined");
|
||||
ok(typeof(window.sessionStorage.key) == "function", "sessionStorage.key is defined");
|
||||
ok(typeof(window.sessionStorage.getItem) == "function", "sessionStorage.getItem is defined");
|
||||
ok(typeof(window.sessionStorage.setItem) == "function", "sessionStorage.setItem is defined");
|
||||
ok(typeof(window.sessionStorage.removeItem) == "function", "sessionStorage.removeItem is defined");
|
||||
ok(typeof(window.sessionStorage.clear) == "function", "sessionStorage.clear is defined");
|
||||
});
|
||||
test("check length", function() {
|
||||
expect(3);
|
||||
ok(window.sessionStorage.length == 0, "length should be 0");
|
||||
window.sessionStorage.setItem("key","value");
|
||||
ok(window.sessionStorage.length == 1, "length should be 1");
|
||||
window.sessionStorage.removeItem("key");
|
||||
ok(window.sessionStorage.length == 0, "length should be 0");
|
||||
});
|
||||
test("check key", function() {
|
||||
expect(3);
|
||||
ok(window.sessionStorage.key(0) == null, "key should be null");
|
||||
window.sessionStorage.setItem("test","value");
|
||||
ok(window.sessionStorage.key(0) == "test", "key should be 'test'");
|
||||
window.sessionStorage.removeItem("test");
|
||||
ok(window.sessionStorage.key(0) == null, "key should be null");
|
||||
});
|
||||
test("check getItem", function() {
|
||||
expect(3);
|
||||
ok(window.sessionStorage.getItem("item") == null, "item should be null");
|
||||
window.sessionStorage.setItem("item","value");
|
||||
ok(window.sessionStorage.getItem("item") == "value", "The value of the item should be 'value'");
|
||||
window.sessionStorage.removeItem("item");
|
||||
ok(window.sessionStorage.getItem("item") == null, "item should be null");
|
||||
});
|
||||
test("check setItem", function() {
|
||||
expect(4);
|
||||
ok(window.sessionStorage.getItem("item") == null, "item should be null");
|
||||
window.sessionStorage.setItem("item","value");
|
||||
ok(window.sessionStorage.getItem("item") == "value", "The value of the item should be 'value'");
|
||||
window.sessionStorage.setItem("item","newval");
|
||||
ok(window.sessionStorage.getItem("item") == "newval", "The value of the item should be 'newval'");
|
||||
window.sessionStorage.removeItem("item");
|
||||
ok(window.sessionStorage.getItem("item") == null, "item should be null");
|
||||
});
|
||||
test("check removeItem", function() {
|
||||
expect(3);
|
||||
ok(window.sessionStorage.getItem("item") == null, "item should be null");
|
||||
window.sessionStorage.setItem("item","value");
|
||||
ok(window.sessionStorage.getItem("item") == "value", "The value of the item should be 'value'");
|
||||
window.sessionStorage.removeItem("item");
|
||||
ok(window.sessionStorage.getItem("item") == null, "item should be null");
|
||||
});
|
||||
test("check clear", function() {
|
||||
expect(11);
|
||||
ok(window.sessionStorage.getItem("item1") == null, "item1 should be null");
|
||||
ok(window.sessionStorage.getItem("item2") == null, "item2 should be null");
|
||||
ok(window.sessionStorage.getItem("item3") == null, "item3 should be null");
|
||||
window.sessionStorage.setItem("item1","value");
|
||||
window.sessionStorage.setItem("item2","value");
|
||||
window.sessionStorage.setItem("item3","value");
|
||||
ok(window.sessionStorage.getItem("item1") == "value", "item1 should be null");
|
||||
ok(window.sessionStorage.getItem("item2") == "value", "item2 should be null");
|
||||
ok(window.sessionStorage.getItem("item3") == "value", "item3 should be null");
|
||||
ok(window.sessionStorage.length == 3, "length should be 3");
|
||||
window.sessionStorage.clear();
|
||||
ok(window.sessionStorage.length == 0, "length should be 0");
|
||||
ok(window.sessionStorage.getItem("item1") == null, "item1 should be null");
|
||||
ok(window.sessionStorage.getItem("item2") == null, "item2 should be null");
|
||||
ok(window.sessionStorage.getItem("item3") == null, "item3 should be null");
|
||||
});
|
||||
test("check dot notation", function() {
|
||||
expect(3);
|
||||
ok(window.sessionStorage.item == null, "item should be null");
|
||||
window.sessionStorage.item = "value";
|
||||
ok(window.sessionStorage.item == "value", "The value of the item should be 'value'");
|
||||
window.sessionStorage.removeItem("item");
|
||||
ok(window.sessionStorage.item == null, "item should be null");
|
||||
});
|
||||
module("Local Storage");
|
||||
test("should exist", function() {
|
||||
expect(7);
|
||||
ok(window.localStorage != null, "localStorage is defined");
|
||||
ok(typeof window.localStorage.length != 'undefined', "localStorage.length is defined");
|
||||
ok(typeof(window.localStorage.key) == "function", "localStorage.key is defined");
|
||||
ok(typeof(window.localStorage.getItem) == "function", "localStorage.getItem is defined");
|
||||
ok(typeof(window.localStorage.setItem) == "function", "localStorage.setItem is defined");
|
||||
ok(typeof(window.localStorage.removeItem) == "function", "localStorage.removeItem is defined");
|
||||
ok(typeof(window.localStorage.clear) == "function", "localStorage.clear is defined");
|
||||
});
|
||||
test("check length", function() {
|
||||
expect(3);
|
||||
ok(window.localStorage.length == 0, "length should be 0");
|
||||
window.localStorage.setItem("key","value");
|
||||
ok(window.localStorage.length == 1, "length should be 1");
|
||||
window.localStorage.removeItem("key");
|
||||
ok(window.localStorage.length == 0, "length should be 0");
|
||||
});
|
||||
test("check key", function() {
|
||||
expect(3);
|
||||
ok(window.localStorage.key(0) == null, "key should be null");
|
||||
window.localStorage.setItem("test","value");
|
||||
ok(window.localStorage.key(0) == "test", "key should be 'test'");
|
||||
window.localStorage.removeItem("test");
|
||||
ok(window.localStorage.key(0) == null, "key should be null");
|
||||
});
|
||||
test("check getItem", function() {
|
||||
expect(3);
|
||||
ok(window.localStorage.getItem("item") == null, "item should be null");
|
||||
window.localStorage.setItem("item","value");
|
||||
ok(window.localStorage.getItem("item") == "value", "The value of the item should be 'value'");
|
||||
window.localStorage.removeItem("item");
|
||||
ok(window.localStorage.getItem("item") == null, "item should be null");
|
||||
});
|
||||
test("check setItem", function() {
|
||||
expect(4);
|
||||
ok(window.localStorage.getItem("item") == null, "item should be null");
|
||||
window.localStorage.setItem("item","value");
|
||||
ok(window.localStorage.getItem("item") == "value", "The value of the item should be 'value'");
|
||||
window.localStorage.setItem("item","newval");
|
||||
ok(window.localStorage.getItem("item") == "newval", "The value of the item should be 'newval'");
|
||||
window.localStorage.removeItem("item");
|
||||
ok(window.localStorage.getItem("item") == null, "item should be null");
|
||||
});
|
||||
test("check removeItem", function() {
|
||||
expect(3);
|
||||
ok(window.localStorage.getItem("item") == null, "item should be null");
|
||||
window.localStorage.setItem("item","value");
|
||||
ok(window.localStorage.getItem("item") == "value", "The value of the item should be 'value'");
|
||||
window.localStorage.removeItem("item");
|
||||
ok(window.localStorage.getItem("item") == null, "item should be null");
|
||||
});
|
||||
test("check clear", function() {
|
||||
expect(11);
|
||||
ok(window.localStorage.getItem("item1") == null, "item1 should be null");
|
||||
ok(window.localStorage.getItem("item2") == null, "item2 should be null");
|
||||
ok(window.localStorage.getItem("item3") == null, "item3 should be null");
|
||||
window.localStorage.setItem("item1","value");
|
||||
window.localStorage.setItem("item2","value");
|
||||
window.localStorage.setItem("item3","value");
|
||||
ok(window.localStorage.getItem("item1") == "value", "item1 should be null");
|
||||
ok(window.localStorage.getItem("item2") == "value", "item2 should be null");
|
||||
ok(window.localStorage.getItem("item3") == "value", "item3 should be null");
|
||||
ok(window.localStorage.length == 3, "length should be 3");
|
||||
window.localStorage.clear();
|
||||
ok(window.localStorage.length == 0, "length should be 0");
|
||||
ok(window.localStorage.getItem("item1") == null, "item1 should be null");
|
||||
ok(window.localStorage.getItem("item2") == null, "item2 should be null");
|
||||
ok(window.localStorage.getItem("item3") == null, "item3 should be null");
|
||||
});
|
||||
test("check dot notation", function() {
|
||||
expect(3);
|
||||
ok(window.localStorage.item == null, "item should be null");
|
||||
window.localStorage.item = "value";
|
||||
ok(window.localStorage.item == "value", "The value of the item should be 'value'");
|
||||
window.localStorage.removeItem("item");
|
||||
ok(window.localStorage.item == null, "item should be null");
|
||||
});
|
||||
module("HTML 5 Storage");
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(typeof(window.openDatabase) == "function", "Database is defined");
|
||||
});
|
||||
test("Should open a database", function() {
|
||||
var db = openDatabase("Database", "1.0", "HTML5 Database API example", 200000);
|
||||
ok(db != null, "Database should be opened");
|
||||
});
|
||||
}
|
@ -1,261 +0,0 @@
|
||||
Tests.prototype.SystemTests = function() {
|
||||
module('System Information (navigator.system)');
|
||||
test("should exist", function() {
|
||||
expect(1);
|
||||
ok(navigator.system != null, "navigator.system should not be null.");
|
||||
});
|
||||
test("should contain a get function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.system.get != 'undefined' && navigator.system.get != null, "navigator.system.get should not be null.");
|
||||
ok(typeof navigator.system.get == 'function', "navigator.system.get should be a function.");
|
||||
});
|
||||
test("should contain a has function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.system.has != 'undefined' && navigator.system.has != null, "navigator.system.has should not be null.");
|
||||
ok(typeof navigator.system.has == 'function', "navigator.system.has should be a function.");
|
||||
});
|
||||
test("should contain a monitor function", function() {
|
||||
expect(2);
|
||||
ok(typeof navigator.system.monitor != 'undefined' && navigator.system.monitor != null, "navigator.system.monitor should not be null.");
|
||||
ok(typeof navigator.system.monitor == 'function', "navigator.system.monitor should be a function.");
|
||||
});
|
||||
module('System Information Options');
|
||||
test("should be able to define a SystemInfoOptions object", function() {
|
||||
expect(6);
|
||||
var systemInfoOptions = new SystemInfoOptions(0.0, 0.0, "a", 0, "b");
|
||||
ok(systemInfoOptions != null, "new SystemInfoOptions() should not be null.");
|
||||
ok(typeof systemInfoOptions.highThreshold != 'undefined' && systemInfoOptions.highThreshold != null && systemInfoOptions.highThreshold == 0.0, "new SystemInfoOptions() should include a 'highThreshold' property.");
|
||||
ok(typeof systemInfoOptions.lowThreshold != 'undefined' && systemInfoOptions.lowThreshold != null && systemInfoOptions.lowThreshold == 0.0, "new SystemInfoOptions() should include a 'lowThreshold' property.");
|
||||
ok(typeof systemInfoOptions.thresholdTarget != 'undefined' && systemInfoOptions.thresholdTarget != null && systemInfoOptions.thresholdTarget == "a", "new SystemInfoOptions() should include a 'thresholdTarget' property.");
|
||||
ok(typeof systemInfoOptions.timeout != 'undefined' && systemInfoOptions.timeout != null && systemInfoOptions.timeout == 0, "new SystemInfoOptions() should include a 'timeout' property.");
|
||||
ok(typeof systemInfoOptions.id != 'undefined' && systemInfoOptions.id != null && systemInfoOptions.id == "b", "new SystemInfoOptions() should include a 'id' property.");
|
||||
});
|
||||
module('Power Property');
|
||||
test("should be able to define a Power Property object", function() {
|
||||
expect(7);
|
||||
var power = new PowerAttributes("a","b",0.0,0,true,false);
|
||||
ok(power != null, "new PowerAttributes() should not be null.");
|
||||
ok(typeof power.info != 'undefined' && power.info != null && power.info == "a", "new PowerAttributes() should include a 'info' property.");
|
||||
ok(typeof power.id != 'undefined' && power.id != null && power.id == "b", "new PowerAttributes() should include a 'id' property.");
|
||||
ok(typeof power.level != 'undefined' && power.level != null && power.level == 0.0, "new PowerAttributes() should include a 'level' property.");
|
||||
ok(typeof power.timeRemaining != 'undefined' && power.timeRemaining != null && power.timeRemaining == 0, "new PowerAttributes() should include a 'timeRemaining' property.");
|
||||
ok(typeof power.isBattery != 'undefined' && power.isBattery != null && power.isBattery == true, "new PowerAttributes() should include a 'isBattery' property.");
|
||||
ok(typeof power.isCharging != 'undefined' && power.isCharging != null && power.isCharging == false, "new PowerAttributes() should include a 'isCharging' property.");
|
||||
});
|
||||
module('CPU Property');
|
||||
test("should be able to define a CPU Property object", function() {
|
||||
expect(4);
|
||||
var cpu = new CPUAttributes("a", "b", 0.0);
|
||||
ok(cpu != null, "new CPUAttributes() should not be null.");
|
||||
ok(typeof cpu.info != 'undefined' && cpu.info != null && cpu.info == "a", "new CPUAttributes() should include a 'info' property.");
|
||||
ok(typeof cpu.id != 'undefined' && cpu.id != null && cpu.id == "b", "new CPUAttributes() should include a 'id' property.");
|
||||
ok(typeof cpu.usage != 'undefined' && cpu.usage != null && cpu.usage == 0.0, "new CPUAttributes() should include a 'usage' property.");
|
||||
});
|
||||
module('Thermal Property');
|
||||
test("should be able to define a Thermal Property object", function() {
|
||||
expect(4);
|
||||
var thermal = new ThermalAttributes("a", "b", 0.0);
|
||||
ok(thermal != null, "new ThermalAttributes() should not be null.");
|
||||
ok(typeof thermal.info != 'undefined' && thermal.info != null && thermal.info == "a", "new ThermalAttributes() should include a 'info' property.");
|
||||
ok(typeof thermal.id != 'undefined' && thermal.id != null && thermal.id == "b", "new ThermalAttributes() should include a 'id' property.");
|
||||
ok(typeof thermal.state != 'undefined' && thermal.state != null && thermal.state == 0.0, "new ThermalAttributes() should include a 'state' property.");
|
||||
});
|
||||
module('Network Property');
|
||||
test("should be able to define a Network Property object", function() {
|
||||
expect(4);
|
||||
var network = new NetworkAttributes("a", "b", []);
|
||||
ok(network != null, "new NetworkAttributes() should not be null.");
|
||||
ok(typeof network.info != 'undefined' && network.info != null && network.info == "a", "new NetworkAttributes() should include a 'info' property.");
|
||||
ok(typeof network.id != 'undefined' && network.id != null && network.id == "b", "new NetworkAttributes() should include a 'id' property.");
|
||||
ok(typeof network.activeConnections != 'undefined' && network.activeConnections != null, "new NetworkAttributes() should include a 'activeConnections' property.");
|
||||
});
|
||||
module('Connection Type Property');
|
||||
test("should be able to define a display Type Property object", function() {
|
||||
expect(10);
|
||||
var connection = new ConnectionAttributes('a', 'b', ConnectionType.UNKNOWN, 0, 0, 0, 0, 0.0, false);
|
||||
ok(connection != null, "new displayAttributes() should not be null.");
|
||||
ok(typeof connection.info != 'undefined' && connection.info != null && connection.info == "a", "new ConnectionAttributes() should include a 'info' property.");
|
||||
ok(typeof connection.id != 'undefined' && connection.id != null && connection.id == "b", "new ConnectionAttributes() should include a 'id' property.");
|
||||
ok(typeof connection.type != 'undefined' && connection.type != null && connection.type == 'unknown', "new ConnectionAttributes() should include a 'type' property.");
|
||||
ok(typeof connection.currentDownloadBandwidth != 'undefined' && connection.currentDownloadBandwidth != null && connection.currentDownloadBandwidth == 0, "new ConnectionAttributes() should include a 'currentDownloadBandwidth' property.");
|
||||
ok(typeof connection.currentUploadBandwidth != 'undefined' && connection.currentUploadBandwidth != null && connection.currentUploadBandwidth == 0, "new ConnectionAttributes() should include a 'currentUploadBandwidth' property.");
|
||||
ok(typeof connection.maxDownloadBandwidth != 'undefined' && connection.maxDownloadBandwidth != null && connection.maxDownloadBandwidth == 0, "new ConnectionAttributes() should include a 'maxDownloadBandwidth' property.");
|
||||
ok(typeof connection.maxUploadBandwidth != 'undefined' && connection.maxUploadBandwidth != null && connection.maxUploadBandwidth == 0, "new ConnectionAttributes() should include a 'maxUploadBandwidth' property.");
|
||||
ok(typeof connection.currentSignalStrength != 'undefined' && connection.currentSignalStrength != null && connection.currentSignalStrength == 0.0, "new ConnectionAttributes() should include a 'currentSignalStrength' property.");
|
||||
ok(typeof connection.roaming != 'undefined' && connection.roaming != null && connection.roaming == false, "new ConnectionAttributes() should include a 'roaming' property.");
|
||||
});
|
||||
module('Sensor Property');
|
||||
test("should be able to define a Sensor Property object", function() {
|
||||
expect(5);
|
||||
var sensor = new SensorAttributes(0.0,0.0,0.0,0.0);
|
||||
ok(sensor != null, "new SensorAttributes() should not be null.");
|
||||
ok(typeof sensor.value != 'undefined' && sensor.value != null && sensor.value == 0.0, "new SensorAttributes() should include a 'value' property.");
|
||||
ok(typeof sensor.min != 'undefined' && sensor.min != null && sensor.min == 0.0, "new SensorAttributes() should include a 'min' property.");
|
||||
ok(typeof sensor.max != 'undefined' && sensor.max != null && sensor.max == 0.0, "new SensorAttributes() should include a 'max' property.");
|
||||
ok(typeof sensor.normalizedValue != 'undefined' && sensor.normalizedValue != null && sensor.normalizedValue == 0.0, "new SensorAttributes() should include a 'normalizedValue' property.");
|
||||
});
|
||||
module('AVCodecs Property');
|
||||
test("should be able to define a AVCodecs Property object", function() {
|
||||
expect(5);
|
||||
var avcodecs = new AVCodecsAttributes("a", "b", [], []);
|
||||
ok(avcodecs != null, "new AVCodecsAttributes() should not be null.");
|
||||
ok(typeof avcodecs.info != 'undefined' && avcodecs.info != null && avcodecs.info == "a", "new AVCodecsAttributes() should include a 'info' property.");
|
||||
ok(typeof avcodecs.id != 'undefined' && avcodecs.id != null && avcodecs.id == "b", "new AVCodecsAttributes() should include a 'id' property.");
|
||||
ok(typeof avcodecs.audioCodecs != 'undefined' && avcodecs.audioCodecs != null, "new AVCodecsAttributes() should include a 'audioCodecs' property.");
|
||||
ok(typeof avcodecs.videoCodecs != 'undefined' && avcodecs.videoCodecs != null, "new AVCodecsAttributes() should include a 'videoCodecs' property.");
|
||||
});
|
||||
module('Audio Codec Property');
|
||||
test("should be able to define a Audio Codec Property object", function() {
|
||||
expect(6);
|
||||
var codec = new AudioCodecAttributes("a", "b", 'a',true,true);
|
||||
ok(codec != null, "new AudioCodecAttributes() should not be null.");
|
||||
ok(typeof codec.info != 'undefined' && codec.info != null && codec.info == "a", "new AudioCodecAttributes() should include a 'info' property.");
|
||||
ok(typeof codec.id != 'undefined' && codec.id != null && codec.id == "b", "new AudioCodecAttributes() should include a 'id' property.");
|
||||
ok(typeof codec.compFormats != 'undefined' && codec.compFormats != null && codec.compFormats == 'a', "new AudioCodecAttributes() should include a 'compFormats' property.");
|
||||
ok(typeof codec.encode != 'undefined' && codec.encode != null && codec.encode == true, "new AudioCodecAttributes() should include a 'encode' property.");
|
||||
ok(typeof codec.decode != 'undefined' && codec.decode != null && codec.decode == true, "new AudioCodecAttributes() should include a 'decode' property.");
|
||||
});
|
||||
module('Video Codec Property');
|
||||
test("should be able to define a Video Codec Property object", function() {
|
||||
expect(9);
|
||||
var codec = new VideoCodecAttributes("a", "b", [],[],[],[],[],[]);
|
||||
ok(codec != null, "new VideoCodecAttributes() should not be null.");
|
||||
ok(typeof codec.info != 'undefined' && codec.info != null && codec.info == "a", "new VideoCodecAttributes() should include a 'info' property.");
|
||||
ok(typeof codec.id != 'undefined' && codec.id != null && codec.id == "b", "new VideoCodecAttributes() should include a 'id' property.");
|
||||
ok(typeof codec.compFormats != 'undefined' && codec.compFormats != null, "new VideoCodecAttributes() should include a 'compFormats' property.");
|
||||
ok(typeof codec.containerFormats != 'undefined' && codec.containerFormats != null, "new VideoCodecAttributes() should include a 'containerFormats' property.");
|
||||
ok(typeof codec.hwAccel != 'undefined' && codec.hwAccel != null, "new VideoCodecAttributes() should include a 'hwAccel' property.");
|
||||
ok(typeof codec.profiles != 'undefined' && codec.profiles != null, "new VideoCodecAttributes() should include a 'profiles' property.");
|
||||
ok(typeof codec.frameTypes != 'undefined' && codec.frameTypes != null, "new VideoCodecAttributes() should include a 'frameTypes' property.");
|
||||
ok(typeof codec.rateTypes != 'undefined' && codec.rateTypes != null, "new VideoCodecAttributes() should include a 'rateTypes' property.");
|
||||
});
|
||||
module('Storage Unit Property');
|
||||
test("should be able to define a Storage Property object", function() {
|
||||
expect(8);
|
||||
var storage = new StorageUnitAttributes('a','b',0,true,0,0,true);
|
||||
ok(storage != null, "new StorageUnitAttributes() should not be null.");
|
||||
ok(typeof storage.info != 'undefined' && storage.info != null && storage.info == "a", "new StorageUnitAttributes() should include a 'info' property.");
|
||||
ok(typeof storage.id != 'undefined' && storage.id != null && storage.id == "b", "new StorageUnitAttributes() should include a 'id' property.");
|
||||
ok(typeof storage.type != 'undefined' && storage.type != null && storage.type == 0, "new StorageUnitAttributes() should include a 'type' property.");
|
||||
ok(typeof storage.isWritable != 'undefined' && storage.isWritable != null && storage.isWritable == true, "new StorageUnitAttributes() should include a 'isWritable' property.");
|
||||
ok(typeof storage.capacity != 'undefined' && storage.capacity != null && storage.capacity == 0, "new StorageUnitAttributes() should include a 'capacity' property.");
|
||||
ok(typeof storage.availableCapacity != 'undefined' && storage.availableCapacity != null && storage.availableCapacity == 0, "new StorageUnitAttributes() should include a 'availableCapacity' property.");
|
||||
ok(typeof storage.isRemoveable != 'undefined' && storage.isRemoveable != null && storage.isRemoveable == true, "new StorageUnitAttributes() should include a 'isRemoveable' property.");
|
||||
});
|
||||
module('Output Devices Property');
|
||||
test("should be able to define a Input Devices Property object", function() {
|
||||
expect(11);
|
||||
var output = new OutputDevicesAttributes('a','b',[],[],[],"a",[],"a",[],[]);
|
||||
ok(output != null, "new OutputDevicesAttributes() should not be null.");
|
||||
ok(typeof output.info != 'undefined' && output.info != null && output.info == "a", "new OutputDevicesAttributes() should include a 'info' property.");
|
||||
ok(typeof output.id != 'undefined' && output.id != null && output.id == "b", "new OutputDevicesAttributes() should include a 'id' property.");
|
||||
ok(typeof output.displayDevices != 'undefined' && output.displayDevices != null, "new OutputDevicesAttributes() should include a 'displayDevices' property.");
|
||||
ok(typeof output.activeDisplayDevices != 'undefined' && output.activeDisplayDevices != null, "new OutputDevicesAttributes() should include a 'activeDisplayDevices' property.");
|
||||
ok(typeof output.printingDevices != 'undefined' && output.printingDevices != null, "new OutputDevicesAttributes() should include a 'printingDevices' property.");
|
||||
ok(typeof output.activePrintingDevice != 'undefined' && output.activePrintingDevice != null && output.activePrintingDevice == "a", "new OutputDevicesAttributes() should include a 'activePrintingDevice' property.");
|
||||
ok(typeof output.brailleDevices != 'undefined' && output.brailleDevices != null, "new OutputDevicesAttributes() should include a 'brailleDevices' property.");
|
||||
ok(typeof output.activeBrailleDevice != 'undefined' && output.activeBrailleDevice != null && output.activeBrailleDevice == "a", "new OutputDevicesAttributes() should include a 'activeBrailleDevice' property.");
|
||||
ok(typeof output.audioDevices != 'undefined' && output.audioDevices != null, "new OutputDevicesAttributes() should include a 'audioDevices' property.");
|
||||
ok(typeof output.activeAudioDevices != 'undefined' && output.activeAudioDevices != null, "new OutputDevicesAttributes() should include a 'activeAudioDevices' property.");
|
||||
});
|
||||
module('Display Device Type Property');
|
||||
test("should be able to define a Display Device Property object", function() {
|
||||
expect(10);
|
||||
var display = new DisplayDeviceAttributes(0,0.0,0.0,true,0,0,0.0,0.0,"a");
|
||||
ok(display != null, "new DisplayDeviceAttributes() should not be null.");
|
||||
ok(typeof display.orientation != 'undefined' && display.orientation != null && display.orientation == 0, "new DisplayDeviceAttributes() should include a 'orientation' property.");
|
||||
ok(typeof display.brightness != 'undefined' && display.brightness != null && display.brightness == 0.0, "new DisplayDeviceAttributes() should include a 'brightness' property.");
|
||||
ok(typeof display.contrast != 'undefined' && display.contrast != null && display.contrast == 0.0, "new DisplayDeviceAttributes() should include a 'contrast' property.");
|
||||
ok(typeof display.blanked != 'undefined' && display.blanked != null && display.blanked == true, "new DisplayDeviceAttributes() should include a 'blanked' property.");
|
||||
ok(typeof display.dotsPerInchW != 'undefined' && display.dotsPerInchW != null && display.dotsPerInchW == 0, "new DisplayDeviceAttributes() should include a 'dotsPerInchW' property.");
|
||||
ok(typeof display.dotsPerInchH != 'undefined' && display.dotsPerInchH != null && display.dotsPerInchH == 0, "new DisplayDeviceAttributes() should include a 'dotsPerInchH' property.");
|
||||
ok(typeof display.physicalWidth != 'undefined' && display.physicalWidth != null && display.physicalWidth == 0.0, "new DisplayDeviceAttributes() should include a 'physicalWidth' property.");
|
||||
ok(typeof display.physicalHeight != 'undefined' && display.physicalHeight != null && display.physicalHeight == 0.0, "new DisplayDeviceAttributes() should include a 'physicalHeight' property.");
|
||||
ok(typeof display.info != 'undefined' && display.info != null && display.info == 'a', "new DisplayDeviceAttributes() should include a 'info' property.");
|
||||
});
|
||||
module('Audio Device Type Property');
|
||||
test("should be able to define a Audio Device Property object", function() {
|
||||
expect(6);
|
||||
var audio = new AudioDeviceAttributes(0,0,0,0,"a");
|
||||
ok(audio != null, "new AudioDeviceAttributes() should not be null.");
|
||||
ok(typeof audio.type != 'undefined' && audio.type != null && audio.type == 0, "new AudioDeviceAttributes() should include a 'type' property.");
|
||||
ok(typeof audio.freqRangeLow != 'undefined' && audio.freqRangeLow != null && audio.freqRangeLow == 0, "new AudioDeviceAttributes() should include a 'freqRangeLow' property.");
|
||||
ok(typeof audio.freqRangeHigh != 'undefined' && audio.freqRangeHigh != null && audio.freqRangeHigh == 0, "new AudioDeviceAttributes() should include a 'freqRangeHigh' property.");
|
||||
ok(typeof audio.volumeLevel != 'undefined' && audio.volumeLevel != null && audio.volumeLevel == 0, "new AudioDeviceAttributes() should include a 'volumeLevel' property.");
|
||||
ok(typeof audio.info != 'undefined' && audio.info != null && audio.info == "a", "new AudioDeviceAttributes() should include a 'info' property.");
|
||||
});
|
||||
module('Printing Device Type Property');
|
||||
test("should be able to define a Printing Device Property object", function() {
|
||||
expect(5);
|
||||
var printer = new PrintingDeviceAttributes(0,0,0,"a");
|
||||
ok(printer != null, "new PrintingDeviceAttributes() should not be null.");
|
||||
ok(typeof printer.type != 'undefined' && printer.type != null && printer.type == 0, "new PrintingDeviceAttributes() should include a 'type' property.");
|
||||
ok(typeof printer.resolution != 'undefined' && printer.resolution != null && printer.resolution == 0, "new PrintingDeviceAttributes() should include a 'resolution' property.");
|
||||
ok(typeof printer.color != 'undefined' && printer.color != null && printer.color == 0, "new PrintingDeviceAttributes() should include a 'color' property.");
|
||||
ok(typeof printer.info != 'undefined' && printer.info != null && printer.info == "a", "new PrintingDeviceAttributes() should include a 'info' property.");
|
||||
});
|
||||
module('Braille Device Type Property');
|
||||
test("should be able to define a Printing Device Property object", function() {
|
||||
expect(3);
|
||||
var braille = new BrailleDeviceAttributes(0,"a");
|
||||
ok(braille != null, "new BrailleDeviceAttributes() should not be null.");
|
||||
ok(typeof braille.nbCells != 'undefined' && braille.nbCells != null && braille.nbCells == 0, "new BrailleDeviceAttributes() should include a 'nbCells' property.");
|
||||
ok(typeof braille.info != 'undefined' && braille.info != null && braille.info == "a", "new BrailleDeviceAttributes() should include a 'info' property.");
|
||||
});
|
||||
module('Input Devices Property');
|
||||
test("should be able to define a Input Devices Property object", function() {
|
||||
expect(11);
|
||||
var input = new InputDevicesAttributes('a','b',[],[],[],[],[],[],[],[]);
|
||||
ok(input != null, "new InputDevicesAttributes() should not be null.");
|
||||
ok(typeof input.info != 'undefined' && input.info != null && input.info == "a", "new InputDevicesAttributes() should include a 'info' property.");
|
||||
ok(typeof input.id != 'undefined' && input.id != null && input.id == "b", "new InputDevicesAttributes() should include a 'id' property.");
|
||||
ok(typeof input.pointingDevices != 'undefined' && input.pointingDevices != null, "new InputDevicesAttributes() should include a 'pointingDevices' property.");
|
||||
ok(typeof input.activePointingDevices != 'undefined' && input.activePointingDevices != null, "new InputDevicesAttributes() should include a 'activePointingDevices' property.");
|
||||
ok(typeof input.keyboards != 'undefined' && input.keyboards != null, "new InputDevicesAttributes() should include a 'keyboards' property.");
|
||||
ok(typeof input.activeKeyboards != 'undefined' && input.activeKeyboards != null, "new InputDevicesAttributes() should include a 'activeKeyboards' property.");
|
||||
ok(typeof input.cameras != 'undefined' && input.cameras != null, "new InputDevicesAttributes() should include a 'cameras' property.");
|
||||
ok(typeof input.activeCameras != 'undefined' && input.activeCameras != null, "new InputDevicesAttributes() should include a 'activeCameras' property.");
|
||||
ok(typeof input.microphones != 'undefined' && input.microphones != null, "new InputDevicesAttributes() should include a 'microphones' property.");
|
||||
ok(typeof input.activeMicrophones != 'undefined' && input.activeMicrophones != null, "new InputDevicesAttributes() should include a 'activeMicrophones' property.");
|
||||
});
|
||||
module('Pointer Property');
|
||||
test("should be able to define a Pointer Property object", function() {
|
||||
expect(4);
|
||||
var pointer = new PointerAttributes(0,true,"a");
|
||||
ok(pointer != null, "new PointerAttributes() should not be null.");
|
||||
ok(typeof pointer.type != 'undefined' && pointer.type != null && pointer.type == 0, "new PointerAttributes() should include a 'type' property.");
|
||||
ok(typeof pointer.supportsMultiTouch != 'undefined' && pointer.supportsMultiTouch != null && pointer.supportsMultiTouch == true, "new PointerAttributes() should include a 'supportsMultiTouch' property.");
|
||||
ok(typeof pointer.info != 'undefined' && pointer.info != null && pointer.info == "a", "new PointerAttributes() should include a 'info' property.");
|
||||
});
|
||||
module('Keyboard Property');
|
||||
test("should be able to define a Keyboard Property object", function() {
|
||||
expect(4);
|
||||
var keyboard = new KeyboardAttributes(0,true,"a");
|
||||
ok(keyboard != null, "new KeyboardAttributes() should not be null.");
|
||||
ok(typeof keyboard.type != 'undefined' && keyboard.type != null && keyboard.type == 0, "new KeyboardAttributes() should include a 'type' property.");
|
||||
ok(typeof keyboard.isHardware != 'undefined' && keyboard.isHardware != null && keyboard.isHardware == true, "new KeyboardAttributes() should include a 'isHardware' property.");
|
||||
ok(typeof keyboard.info != 'undefined' && keyboard.info != null && keyboard.info == "a", "new KeyboardAttributes() should include a 'info' property.");
|
||||
});
|
||||
module('Camera Property');
|
||||
test("should be able to define a Camera Property object", function() {
|
||||
expect(5);
|
||||
var camera = new CameraAttributes(true,true,0,0.0);
|
||||
ok(camera != null, "new CameraAttributes() should not be null.");
|
||||
ok(typeof camera.supportsVideo != 'undefined' && camera.supportsVideo != null && camera.supportsVideo == true, "new CameraAttributes() should include a 'supportsVideo' property.");
|
||||
ok(typeof camera.hasFlash != 'undefined' && camera.hasFlash != null && camera.hasFlash == true, "new CameraAttributes() should include a 'hasFlash' property.");
|
||||
ok(typeof camera.sensorPixels != 'undefined' && camera.sensorPixels != null && camera.sensorPixels == 0, "new CameraAttributes() should include a 'sensorPixels' property.");
|
||||
ok(typeof camera.maxZoomFactor != 'undefined' && camera.maxZoomFactor != null && camera.maxZoomFactor == 0.0, "new CameraAttributes() should include a 'maxZoomFactor' property.");
|
||||
});
|
||||
module('Microphone Property');
|
||||
test("should be able to define a Microphone Property object", function() {
|
||||
expect(7);
|
||||
var mic = new MicrophoneAttributes(0,0,0,"a","b",[]);
|
||||
ok(mic != null, "new MicrophoneAttributes() should not be null.");
|
||||
ok(typeof mic.type != 'undefined' && mic.type != null && mic.type == 0, "new MicrophoneAttributes() should include a 'type' property.");
|
||||
ok(typeof mic.freqRangeLow != 'undefined' && mic.freqRangeLow != null && mic.freqRangeLow == 0, "new MicrophoneAttributes() should include a 'freqRangeLow' property.");
|
||||
ok(typeof mic.freqRangeHigh != 'undefined' && mic.freqRangeHigh != null && mic.freqRangeHigh == 0, "new MicrophoneAttributes() should include a 'freqRangeHigh' property.");
|
||||
ok(typeof mic.info != 'undefined' && mic.info != null && mic.info == "a", "new MicrophoneAttributes() should include a 'info' property.");
|
||||
ok(typeof mic.name != 'undefined' && mic.name != null && mic.name == "b", "new MicrophoneAttributes() should include a 'name' property.");
|
||||
ok(typeof mic.types != 'undefined' && mic.types != null, "new MicrophoneAttributes() should include a 'types' property.");
|
||||
});
|
||||
};
|
@ -1,96 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
/* Battery */
|
||||
function updateInfo(info) {
|
||||
document.getElementById('level').innerText = info.level;
|
||||
document.getElementById('isPlugged').innerText = info.isPlugged;
|
||||
if (info.level > 5) {
|
||||
document.getElementById('crit').innerText = "false";
|
||||
}
|
||||
if (info.level > 20) {
|
||||
document.getElementById('low').innerText = "false";
|
||||
}
|
||||
}
|
||||
|
||||
function batteryLow(info) {
|
||||
document.getElementById('low').innerText = "true";
|
||||
}
|
||||
|
||||
function batteryCritical(info) {
|
||||
document.getElementById('crit').innerText = "true";
|
||||
}
|
||||
|
||||
function addBattery() {
|
||||
window.addEventListener("batterystatus", updateInfo, false);
|
||||
}
|
||||
|
||||
function removeBattery() {
|
||||
window.removeEventListener("batterystatus", updateInfo, false);
|
||||
}
|
||||
|
||||
function addLow() {
|
||||
window.addEventListener("batterylow", batteryLow, false);
|
||||
}
|
||||
|
||||
function removeLow() {
|
||||
window.removeEventListener("batterylow", batteryLow, false);
|
||||
}
|
||||
|
||||
function addCritical() {
|
||||
window.addEventListener("batterycritical", batteryCritical, false);
|
||||
}
|
||||
|
||||
function removeCritical() {
|
||||
window.removeEventListener("batterycritical", batteryCritical, false);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Battery</h1>
|
||||
<div id="info">
|
||||
<b>Status:</b> <span id="battery_status"></span><br>
|
||||
Level: <span id="level"></span><br/>
|
||||
Plugged: <span id="isPlugged"></span><br/>
|
||||
Low: <span id="low"></span><br/>
|
||||
Critical: <span id="crit"></span><br/>
|
||||
</div>
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="addBattery();">Add "batterystatus" listener</a>
|
||||
<a href="javascript:" class="btn large" onclick="removeBattery();">Remove "batterystatus" listener</a>
|
||||
<a href="javascript:" class="btn large" onclick="addLow();">Add "batterylow" listener</a>
|
||||
<a href="javascript:" class="btn large" onclick="removeLow();">Remove "batterylow" listener</a>
|
||||
<a href="javascript:" class="btn large" onclick="addCritical();">Add "batterycritical" listener</a>
|
||||
<a href="javascript:" class="btn large" onclick="removeCritical();">Remove "batterycritical" listener</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
@ -1,96 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Camera
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Capture picture
|
||||
*/
|
||||
function getPicture() {
|
||||
|
||||
//navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
|
||||
// destinationType: Camera.DestinationType.FILE_URI, sourceType : Camera.PictureSourceType.CAMERA });
|
||||
|
||||
navigator.camera.getPicture(
|
||||
function(data) {
|
||||
var img = document.getElementById('camera_image');
|
||||
img.style.visibility = "visible";
|
||||
img.style.display = "block";
|
||||
//img.src = "data:image/jpeg;base64," + data;
|
||||
img.src = data;
|
||||
document.getElementById('camera_status').innerHTML = "Success";
|
||||
},
|
||||
function(e) {
|
||||
console.log("Error getting picture: " + e);
|
||||
document.getElementById('camera_status').innerHTML = "Error getting picture.";
|
||||
},
|
||||
{ quality: 50, destinationType:
|
||||
Camera.DestinationType.FILE_URI, sourceType : Camera.PictureSourceType.CAMERA});
|
||||
};
|
||||
|
||||
/**
|
||||
* Select image from library
|
||||
*/
|
||||
function getImage() {
|
||||
navigator.camera.getPicture(
|
||||
function(data) {
|
||||
var img = document.getElementById('camera_image');
|
||||
img.style.visibility = "visible";
|
||||
img.style.display = "block";
|
||||
//img.src = "data:image/jpeg;base64," + data;
|
||||
img.src = data;
|
||||
document.getElementById('camera_status').innerHTML = "Success";
|
||||
},
|
||||
function(e) {
|
||||
console.log("Error getting picture: " + e);
|
||||
document.getElementById('camera_status').innerHTML = "Error getting picture.";
|
||||
},
|
||||
{ quality: 50, destinationType:
|
||||
Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Camera</h1>
|
||||
<div id="info">
|
||||
<b>Status:</b> <span id="camera_status"></span><br>
|
||||
<img style="width:120px;height:120px;visibility:hidden;display:none;" id="camera_image" src="" />
|
||||
</div>
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="getPicture();">Take Picture</a>
|
||||
<a href="javascript:" class="btn large" onclick="getImage();">Select Image from Library</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
@ -1,128 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
function roundNumber(num) {
|
||||
var dec = 3;
|
||||
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Compass
|
||||
//-------------------------------------------------------------------------
|
||||
var watchCompassId = null;
|
||||
|
||||
/**
|
||||
* Start watching compass
|
||||
*/
|
||||
var watchCompass = function() {
|
||||
console.log("watchCompass()");
|
||||
|
||||
// Success callback
|
||||
var success = function(a){
|
||||
document.getElementById('compassHeading').innerHTML = roundNumber(a.magneticHeading);
|
||||
};
|
||||
|
||||
// Fail callback
|
||||
var fail = function(e){
|
||||
console.log("watchCompass fail callback with error code "+e);
|
||||
stopCompass();
|
||||
setCompassStatus(e);
|
||||
};
|
||||
|
||||
// Update heading every 1 sec
|
||||
var opt = {};
|
||||
opt.frequency = 1000;
|
||||
watchCompassId = navigator.compass.watchHeading(success, fail, opt);
|
||||
|
||||
setCompassStatus("Running");
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop watching the acceleration
|
||||
*/
|
||||
var stopCompass = function() {
|
||||
setCompassStatus("Stopped");
|
||||
if (watchCompassId) {
|
||||
navigator.compass.clearWatch(watchCompassId);
|
||||
watchCompassId = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get current compass
|
||||
*/
|
||||
var getCompass = function() {
|
||||
console.log("getCompass()");
|
||||
|
||||
// Stop compass if running
|
||||
stopCompass();
|
||||
|
||||
// Success callback
|
||||
var success = function(a){
|
||||
document.getElementById('compassHeading').innerHTML = roundNumber(a.magneticHeading);
|
||||
};
|
||||
|
||||
// Fail callback
|
||||
var fail = function(e){
|
||||
console.log("getCompass fail callback with error code "+e);
|
||||
setCompassStatus(e);
|
||||
};
|
||||
|
||||
// Make call
|
||||
var opt = {};
|
||||
navigator.compass.getCurrentHeading(success, fail, opt);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set compass status
|
||||
*/
|
||||
var setCompassStatus = function(status) {
|
||||
document.getElementById('compass_status').innerHTML = status;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Compass</h1>
|
||||
<div id="info">
|
||||
<b>Status:</b> <span id="compass_status">Stopped</span>
|
||||
<table width="100%"><tr>
|
||||
<td width="33%">Heading: <span id="compassHeading"> </span></td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="getCompass();">Get Compass</a>
|
||||
<a href="javascript:" class="btn large" onclick="watchCompass();">Start Watching Compass</a>
|
||||
<a href="javascript:" class="btn large" onclick="stopCompass();">Stop Watching Compass</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
@ -1,112 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Contacts
|
||||
//-------------------------------------------------------------------------
|
||||
function getContacts() {
|
||||
obj = new ContactFindOptions();
|
||||
obj.filter = "D"; //Brooks";
|
||||
obj.multiple = true;
|
||||
navigator.contacts.find(
|
||||
["displayName", "name", "phoneNumbers", "emails", "urls", "note"],
|
||||
function(contacts) {
|
||||
var s = "";
|
||||
if (contacts.length == 0) {
|
||||
s = "No contacts found";
|
||||
}
|
||||
else {
|
||||
s = "Number of contacts: "+contacts.length+"<br><table width='100%'><tr><th>Name</th><td>Phone</td><td>Email</td></tr>";
|
||||
for (var i=0; i<contacts.length; i++) {
|
||||
var contact = contacts[i];
|
||||
s = s + "<tr><td>" + contact.name.formatted + "</td><td>";
|
||||
if (contact.phoneNumbers && contact.phoneNumbers.length > 0) {
|
||||
s = s + contact.phoneNumbers[0].value;
|
||||
}
|
||||
s = s + "</td><td>"
|
||||
if (contact.emails && contact.emails.length > 0) {
|
||||
s = s + contact.emails[0].value;
|
||||
}
|
||||
s = s + "</td></tr>";
|
||||
}
|
||||
s = s + "</table>";
|
||||
}
|
||||
document.getElementById('contacts_results').innerHTML = s;
|
||||
},
|
||||
function(e) {
|
||||
document.getElementById('contacts_results').innerHTML = "Error: "+e.code;
|
||||
},
|
||||
obj);
|
||||
};
|
||||
|
||||
function addContact(){
|
||||
console.log("addContact()");
|
||||
try{
|
||||
var contact = navigator.contacts.create({"displayName": "Dooney Evans"});
|
||||
var contactName = {
|
||||
formatted: "Dooney Evans",
|
||||
familyName: "Evans",
|
||||
givenName: "Dooney",
|
||||
middleName: ""
|
||||
};
|
||||
|
||||
contact.name = contactName;
|
||||
|
||||
var phoneNumbers = [1];
|
||||
phoneNumbers[0] = new ContactField('work', '512-555-1234', true);
|
||||
contact.phoneNumbers = phoneNumbers;
|
||||
|
||||
contact.save(
|
||||
function() { alert("Contact saved.");},
|
||||
function(e) { alert("Contact save failed: " + e.code); }
|
||||
);
|
||||
console.log("you have saved the contact");
|
||||
}
|
||||
catch (e){
|
||||
alert(e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Contacts</h1>
|
||||
<div id="info">
|
||||
<b>Results:</b><br>
|
||||
<span id="contacts_results"> </span>
|
||||
</div>
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="getContacts();">Get phone's contacts</a>
|
||||
<a href="javascript:" class="btn large" onclick="addContact();">Add a new contact 'Dooney Evans'</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
5510
test/assets/www/cordova-1.4.1.js
vendored
5510
test/assets/www/cordova-1.4.1.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,72 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
function interceptBackbutton() {
|
||||
eventOutput("Back button intercepted");
|
||||
}
|
||||
function interceptMenubutton() {
|
||||
eventOutput("Menu button intercepted");
|
||||
}
|
||||
function interceptSearchbutton() {
|
||||
eventOutput("Search button intercepted");
|
||||
}
|
||||
|
||||
var eventOutput = function(s) {
|
||||
var el = document.getElementById("results");
|
||||
el.innerHTML = el.innerHTML + s + "<br>";
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
eventOutput("deviceready event: "+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
document.addEventListener("resume", function() {eventOutput("resume event");}, false);
|
||||
document.addEventListener("pause", function() {eventOutput("pause event");}, false);
|
||||
window.addEventListener("online", function() {eventOutput("online event");});
|
||||
window.addEventListener("offline", function() {eventOutput("offline event");});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Events</h1>
|
||||
<div id="info">
|
||||
<b>Results:</b><br>
|
||||
<span id="results"></span>
|
||||
</div>
|
||||
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="document.addEventListener('backbutton', interceptBackbutton, false);">Intercept backbutton</a>
|
||||
<a href="javascript:" class="btn large" onclick="document.removeEventListener('backbutton', interceptBackbutton, false);">Stop intercept of backbutton</a>
|
||||
<a href="javascript:" class="btn large" onclick="document.addEventListener('menubutton', interceptMenubutton, false);">Intercept menubutton</a>
|
||||
<a href="javascript:" class="btn large" onclick="document.removeEventListener('menubutton', interceptMenubutton, false);">Stop intercept of menubutton</a>
|
||||
<a href="javascript:" class="btn large" onclick="document.addEventListener('searchbutton', interceptSearchbutton, false);">Intercept searchbutton</a>
|
||||
<a href="javascript:" class="btn large" onclick="document.removeEventListener('searchbutton', interceptSearchbutton, false);">Stop intercept of searchbutton</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
@ -1,36 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
<h1>PhoneGap Tests</h1>
|
||||
<div id="info">
|
||||
<h4>Platform: <span id="platform"> </span></h4>
|
||||
<h4>Version: <span id="version"> </span></h4>
|
||||
<h4>UUID: <span id="uuid"> </span></h4>
|
||||
<h4>Name: <span id="name"> </span></h4>
|
||||
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||
</div>
|
||||
<a href="autotest/index.html" class="btn large">Automatic Test</a>
|
||||
<a href="accelerometer/index.html" class="btn large">Accelerometer</a>
|
||||
<a href="audio/index.html" class="btn large">Audio Play/Record</a>
|
||||
<a href="battery/index.html" class="btn large">Battery</a>
|
||||
<a href="camera/index.html" class="btn large">Camera</a>
|
||||
<a href="compass/index.html" class="btn large">Compass</a>
|
||||
<a href="contacts/index.html" class="btn large">Contacts</a>
|
||||
<a href="events/index.html" class="btn large">Events</a>
|
||||
<a href="location/index.html" class="btn large">Location</a>
|
||||
<a href="misc/index.html" class="btn large">Misc Content</a>
|
||||
<a href="notification/index.html" class="btn large">Notification</a>
|
||||
<a href="sql/index.html" class="btn large">Web SQL</a>
|
||||
<a href="storage/index.html" class="btn large">Local Storage</a>
|
||||
</body>
|
||||
</html>
|
@ -1,123 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Location
|
||||
//-------------------------------------------------------------------------
|
||||
var watchLocationId = null;
|
||||
|
||||
/**
|
||||
* Start watching location
|
||||
*/
|
||||
var watchLocation = function() {
|
||||
console.log("watchLocation()");
|
||||
|
||||
// Success callback
|
||||
var success = function(p){
|
||||
document.getElementById('latitude').innerHTML = p.coords.latitude;
|
||||
document.getElementById('longitude').innerHTML = p.coords.longitude;
|
||||
};
|
||||
|
||||
// Fail callback
|
||||
var fail = function(e){
|
||||
console.log("watchLocation fail callback with error code "+e);
|
||||
stopLocation();
|
||||
};
|
||||
|
||||
// Get location
|
||||
watchLocationId = navigator.geolocation.watchPosition(success, fail, {enableHighAccuracy: true});
|
||||
setLocationStatus("Running");
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop watching the location
|
||||
*/
|
||||
var stopLocation = function() {
|
||||
setLocationStatus("Stopped");
|
||||
if (watchLocationId) {
|
||||
navigator.geolocation.clearWatch(watchLocationId);
|
||||
watchLocationId = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get current location
|
||||
*/
|
||||
var getLocation = function() {
|
||||
console.log("getLocation()");
|
||||
|
||||
// Stop location if running
|
||||
stopLocation();
|
||||
|
||||
// Success callback
|
||||
var success = function(p){
|
||||
document.getElementById('latitude').innerHTML = p.coords.latitude;
|
||||
document.getElementById('longitude').innerHTML = p.coords.longitude;
|
||||
setLocationStatus("Done");
|
||||
};
|
||||
|
||||
// Fail callback
|
||||
var fail = function(e){
|
||||
console.log("getLocation fail callback with error code "+e.code);
|
||||
setLocationStatus("Error: "+e.code);
|
||||
};
|
||||
|
||||
// Get location
|
||||
navigator.geolocation.getCurrentPosition(success, fail, {enableHighAccuracy: true}); //, {timeout: 10000});
|
||||
setLocationStatus("Retrieving location...");
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Set location status
|
||||
*/
|
||||
var setLocationStatus = function(status) {
|
||||
document.getElementById('location_status').innerHTML = status;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Location</h1>
|
||||
<div id="info">
|
||||
<b>Status:</b> <span id="location_status">Stopped</span>
|
||||
<table width="100%">
|
||||
<tr><td><b>Latitude:</b></td><td id="latitude"> </td></tr>
|
||||
<tr><td><b>Longitude:</b></td><td id="longitude"> </td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="getLocation();">Get Location</a>
|
||||
<a href="javascript:" class="btn large" onclick="watchLocation();">Start Watching Location</a>
|
||||
<a href="javascript:" class="btn large" onclick="stopLocation();">Stop Watching Location</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
@ -1,140 +0,0 @@
|
||||
var deviceInfo = function() {
|
||||
document.getElementById("platform").innerHTML = device.platform;
|
||||
document.getElementById("version").innerHTML = device.version;
|
||||
document.getElementById("uuid").innerHTML = device.uuid;
|
||||
document.getElementById("name").innerHTML = device.name;
|
||||
document.getElementById("width").innerHTML = screen.width;
|
||||
document.getElementById("height").innerHTML = screen.height;
|
||||
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
|
||||
};
|
||||
|
||||
var getLocation = function() {
|
||||
var suc = function(p) {
|
||||
alert(p.coords.latitude + " " + p.coords.longitude);
|
||||
};
|
||||
var locFail = function() {
|
||||
};
|
||||
navigator.geolocation.getCurrentPosition(suc, locFail);
|
||||
};
|
||||
|
||||
var beep = function() {
|
||||
navigator.notification.beep(2);
|
||||
};
|
||||
|
||||
var vibrate = function() {
|
||||
navigator.notification.vibrate(0);
|
||||
};
|
||||
|
||||
function roundNumber(num) {
|
||||
var dec = 3;
|
||||
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
|
||||
return result;
|
||||
}
|
||||
|
||||
var accelerationWatch = null;
|
||||
|
||||
function updateAcceleration(a) {
|
||||
document.getElementById('x').innerHTML = roundNumber(a.x);
|
||||
document.getElementById('y').innerHTML = roundNumber(a.y);
|
||||
document.getElementById('z').innerHTML = roundNumber(a.z);
|
||||
}
|
||||
|
||||
var toggleAccel = function() {
|
||||
if (accelerationWatch !== null) {
|
||||
navigator.accelerometer.clearWatch(accelerationWatch);
|
||||
updateAcceleration({
|
||||
x : "",
|
||||
y : "",
|
||||
z : ""
|
||||
});
|
||||
accelerationWatch = null;
|
||||
} else {
|
||||
var options = {};
|
||||
options.frequency = 1000;
|
||||
accelerationWatch = navigator.accelerometer.watchAcceleration(
|
||||
updateAcceleration, function(ex) {
|
||||
alert("accel fail (" + ex.name + ": " + ex.message + ")");
|
||||
}, options);
|
||||
}
|
||||
};
|
||||
|
||||
var preventBehavior = function(e) {
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
function dump_pic(data) {
|
||||
var viewport = document.getElementById('viewport');
|
||||
console.log(data);
|
||||
viewport.style.display = "";
|
||||
viewport.style.position = "absolute";
|
||||
viewport.style.top = "10px";
|
||||
viewport.style.left = "10px";
|
||||
document.getElementById("test_img").src = "data:image/jpeg;base64," + data;
|
||||
}
|
||||
|
||||
function fail(msg) {
|
||||
alert(msg);
|
||||
}
|
||||
|
||||
function show_pic() {
|
||||
navigator.camera.getPicture(dump_pic, fail, {
|
||||
quality : 50
|
||||
});
|
||||
}
|
||||
|
||||
function close() {
|
||||
var viewport = document.getElementById('viewport');
|
||||
viewport.style.position = "relative";
|
||||
viewport.style.display = "none";
|
||||
}
|
||||
|
||||
// This is just to do this.
|
||||
function readFile() {
|
||||
navigator.file.read('/sdcard/phonegap.txt', fail, fail);
|
||||
}
|
||||
|
||||
function writeFile() {
|
||||
navigator.file.write('foo.txt', "This is a test of writing to a file",
|
||||
fail, fail);
|
||||
}
|
||||
|
||||
function contacts_success(contacts) {
|
||||
alert(contacts.length
|
||||
+ ' contacts returned.'
|
||||
+ (contacts[2] && contacts[2].name ? (' Third contact is ' + contacts[2].name.formatted)
|
||||
: ''));
|
||||
}
|
||||
|
||||
function get_contacts() {
|
||||
var obj = new ContactFindOptions();
|
||||
obj.filter = "";
|
||||
obj.multiple = true;
|
||||
obj.limit = 5;
|
||||
navigator.service.contacts.find(
|
||||
[ "displayName", "name" ], contacts_success,
|
||||
fail, obj);
|
||||
}
|
||||
|
||||
var networkReachableCallback = function(reachability) {
|
||||
// There is no consistency on the format of reachability
|
||||
var networkState = reachability.code || reachability;
|
||||
|
||||
var currentState = {};
|
||||
currentState[NetworkStatus.NOT_REACHABLE] = 'No network connection';
|
||||
currentState[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';
|
||||
currentState[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
|
||||
|
||||
confirm("Connection type:\n" + currentState[networkState]);
|
||||
};
|
||||
|
||||
function check_network() {
|
||||
navigator.network.isReachable("www.mobiledevelopersolutions.com",
|
||||
networkReachableCallback, {});
|
||||
}
|
||||
|
||||
function init() {
|
||||
// the next line makes it impossible to see Contacts on the HTC Evo since it
|
||||
// doesn't have a scroll button
|
||||
// document.addEventListener("touchmove", preventBehavior, false);
|
||||
document.addEventListener("deviceready", deviceInfo, true);
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
body {
|
||||
background:#222 none repeat scroll 0 0;
|
||||
color:#666;
|
||||
font-family:Helvetica;
|
||||
font-size:72%;
|
||||
line-height:1.5em;
|
||||
margin:0;
|
||||
border-top:1px solid #393939;
|
||||
}
|
||||
|
||||
#info{
|
||||
background:#ffa;
|
||||
border: 1px solid #ffd324;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
clear:both;
|
||||
margin:15px 6px 0;
|
||||
width:295px;
|
||||
padding:4px 0px 2px 10px;
|
||||
}
|
||||
|
||||
#info > h4{
|
||||
font-size:.95em;
|
||||
margin:5px 0;
|
||||
}
|
||||
|
||||
#stage.theme{
|
||||
padding-top:3px;
|
||||
}
|
||||
|
||||
/* Definition List */
|
||||
#stage.theme > dl{
|
||||
padding-top:10px;
|
||||
clear:both;
|
||||
margin:0;
|
||||
list-style-type:none;
|
||||
padding-left:10px;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#stage.theme > dl > dt{
|
||||
font-weight:bold;
|
||||
float:left;
|
||||
margin-left:5px;
|
||||
}
|
||||
|
||||
#stage.theme > dl > dd{
|
||||
width:45px;
|
||||
float:left;
|
||||
color:#a87;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
/* Content Styling */
|
||||
#stage.theme > h1, #stage.theme > h2, #stage.theme > p{
|
||||
margin:1em 0 .5em 13px;
|
||||
}
|
||||
|
||||
#stage.theme > h1{
|
||||
color:#eee;
|
||||
font-size:1.6em;
|
||||
text-align:center;
|
||||
margin:0;
|
||||
margin-top:15px;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
#stage.theme > h2{
|
||||
clear:both;
|
||||
margin:0;
|
||||
padding:3px;
|
||||
font-size:1em;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
/* Stage Buttons */
|
||||
#stage.theme a.btn{
|
||||
border: 1px solid #555;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
text-align:center;
|
||||
display:block;
|
||||
float:left;
|
||||
background:#444;
|
||||
width:150px;
|
||||
color:#9ab;
|
||||
font-size:1.1em;
|
||||
text-decoration:none;
|
||||
padding:1.2em 0;
|
||||
margin:3px 0px 3px 5px;
|
||||
}
|
||||
#stage.theme a.btn.large{
|
||||
width:308px;
|
||||
padding:1.2em 0;
|
||||
}
|
||||
#stage.theme a.backBtn{
|
||||
border: 1px solid #555;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
text-align:center;
|
||||
display:block;
|
||||
float:right;
|
||||
background:#666;
|
||||
width:75px;
|
||||
color:#9ab;
|
||||
font-size:1.1em;
|
||||
text-decoration:none;
|
||||
padding:1.2em 0;
|
||||
margin:3px 5px 3px 5px;
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
function roundNumber(num) {
|
||||
var dec = 3;
|
||||
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Display Other Content</h1>
|
||||
<div id="info">
|
||||
</div>
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="document.location='tel:5551212';" >Call 411</a>
|
||||
<a href="mailto:bob@abc.org?subject=My Subject&body=This is the body.%0D%0ANew line." class="btn large">Send Mail</a>
|
||||
<a href="sms:5125551234?body=The SMS message." class="btn large">Send SMS</a>
|
||||
<a href="http://www.google.com" class="btn large">Load Web Site</a>
|
||||
<!-- Need new URL -->
|
||||
<!-- a href="http://handle.library.cornell.edu/control/authBasic/authTest/" class="btn large">Basic Auth: test/this</a -->
|
||||
<a href="page2.html?me=test" class="btn large">Load another PhoneGap page</a>
|
||||
<h2>Android Only</h2>
|
||||
<a href="geo:0,0?q=11400 Burnet Rd, Austin, TX" class="btn large">Map IBM</a>
|
||||
<a href="market://search?q=google" class="btn large">Search Android market</a>
|
||||
<a href="content://media/external/images/media" class="btn large">View image app</a>
|
||||
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
@ -1,25 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="../main.js"></script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
<h1>Page2 App</h1>
|
||||
<h2>This is page 2 of a PhoneGap app</h2>
|
||||
<div id="info">
|
||||
<h4>Platform: <span id="platform"> </span></h4>
|
||||
<h4>Version: <span id="version"> </span></h4>
|
||||
<h4>UUID: <span id="uuid"> </span></h4>
|
||||
<h4>Name: <span id="name"> </span></h4>
|
||||
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||
</div>
|
||||
<div><button onclick="history.back();">Back</button></div>
|
||||
</body>
|
||||
</html>
|
@ -1,81 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Notifications
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
var beep = function(){
|
||||
navigator.notification.beep(3);
|
||||
};
|
||||
|
||||
var vibrate = function(){
|
||||
navigator.notification.vibrate(0);
|
||||
};
|
||||
|
||||
var alertDialog = function(message, title, button) {
|
||||
console.log("alertDialog()");
|
||||
navigator.notification.alert(message,
|
||||
function(){
|
||||
console.log("Alert dismissed.");
|
||||
},
|
||||
title, button);
|
||||
console.log("After alert");
|
||||
};
|
||||
|
||||
var confirmDialog = function(message, title, buttons) {
|
||||
navigator.notification.confirm(message,
|
||||
function(r) {
|
||||
console.log("You selected " + r);
|
||||
alert("You selected " + (buttons.split(","))[r-1]);
|
||||
},
|
||||
title,
|
||||
buttons);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Notifications and Dialogs</h1>
|
||||
<div id="info">
|
||||
</div>
|
||||
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="beep();">Beep</a>
|
||||
<a href="javascript:" class="btn large" onclick="vibrate();">Vibrate</a>
|
||||
<a href="javascript:" class="btn large" onclick="alertDialog('You pressed alert.', 'Alert Dialog', 'Continue');">Alert Dialog</a>
|
||||
<a href="javascript:" class="btn large" onclick="confirmDialog('You pressed confirm.', 'Confirm Dialog', 'Yes,No,Maybe');">Confirm Dialog</a>
|
||||
<a href="javascript:" class="btn large" onclick="alert('You pressed alert.');">Built-in Alert Dialog</a>
|
||||
<a href="javascript:" class="btn large" onclick="confirm('You selected confirm');">Built-in Confirm Dialog</a>
|
||||
<a href="javascript:" class="btn large" onclick="prompt('This is a prompt.', 'Default value');">Built-in Prompt Dialog</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
@ -1,11 +0,0 @@
|
||||
document.write('<script type="text/javascript" charset="utf-8" src="../cordova-1.4.1.js"></script>');
|
||||
document.write('<script type="text/javascript" charset="utf-8" src="cordova-1.4.1.js"></script>');
|
||||
|
||||
function backHome() {
|
||||
if (device.platform.toLowerCase() == 'android') {
|
||||
navigator.app.backHistory();
|
||||
}
|
||||
else {
|
||||
document.location = "../index.html";
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// HTML5 Database
|
||||
//-------------------------------------------------------------------------
|
||||
var db;
|
||||
var callDatabase = function() {
|
||||
db = openDatabase("mydb", "1.0", "PhoneGap Demo", 20000);
|
||||
if (db === null) {
|
||||
databaseOutput("Database could not be opened.");
|
||||
return;
|
||||
}
|
||||
databaseOutput("Database opened.");
|
||||
db.transaction(function (tx) {
|
||||
tx.executeSql('DROP TABLE IF EXISTS DEMO');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)', [],
|
||||
function(tx,results) { console.log("Created table"); },
|
||||
function(tx,err) { alert("Error creating table: "+err.message); });
|
||||
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")', [],
|
||||
function(tx,results) { console.log("Insert row1 success"); },
|
||||
function(tx,err) { alert("Error adding 1st row: "+err.message); });
|
||||
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")', [],
|
||||
function(tx,results) { console.log("Insert row2 success"); },
|
||||
function(tx,err) { alert("Error adding 2nd row: "+err.message); });
|
||||
databaseOutput("Data written to DEMO table.");
|
||||
console.log("Data written to DEMO table.");
|
||||
|
||||
tx.executeSql('SELECT * FROM DEMO', [], function (tx, results) {
|
||||
var len = results.rows.length;
|
||||
var text = "DEMO table: " + len + " rows found.<br>";
|
||||
text = text + "<table border='1'><tr><td>Row</td><td>Data</td></tr>";
|
||||
for (var i=0; i<len; i++){
|
||||
text = text + "<tr><td>" + i + "</td><td>" + results.rows.item(i).id + ", " + results.rows.item(i).data + "</td></tr>";
|
||||
}
|
||||
text = text + "</table>";
|
||||
databaseOutput(text);
|
||||
}, function(tx, err) {
|
||||
alert("Error processing SELECT * SQL: "+err.message);
|
||||
});
|
||||
tx.executeSql('SELECT ID FROM DEMO', [], function (tx, results) {
|
||||
var len = results.rows.length;
|
||||
var text = "DEMO table: " + len + " rows found.<br>";
|
||||
text = text + "<table border='1'><tr><td>Row</td><td>Data</td></tr>";
|
||||
for (var i=0; i<len; i++){
|
||||
text = text + "<tr><td>" + i + "</td><td>" + results.rows.item(i).id + "</td></tr>";
|
||||
}
|
||||
text = text + "</table>";
|
||||
databaseOutput(text);
|
||||
}, function(tx, err) {
|
||||
alert("Error processing SELECT ID SQL: "+err.message);
|
||||
});
|
||||
|
||||
},
|
||||
function(err) {
|
||||
console.log("Transaction failed: " + err.message);
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
var readDatabase = function() {
|
||||
if (!db) {
|
||||
db = openDatabase("mydb", "1.0", "PhoneGap Demo", 20000);
|
||||
if (db === null) {
|
||||
databaseOutput("Database could not be opened.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
db.transaction(function (tx) {
|
||||
tx.executeSql('SELECT * FROM DEMO WHERE id=2', [], function (tx, results) {
|
||||
var len = results.rows.length;
|
||||
var text = "DEMO table: " + len + " rows found.<br>";
|
||||
text = text + "<table border='1'><tr><td>Row</td><td>Data</td></tr>";
|
||||
for (var i=0; i<len; i++){
|
||||
text = text + "<tr><td>" + i + "</td><td>" + results.rows.item(i).id + ", " + results.rows.item(i).data + "</td></tr>";
|
||||
}
|
||||
text = text + "</table>";
|
||||
databaseOutput(text);
|
||||
}, function(tx, err) {
|
||||
alert("Error processing SELECT * WHERE id=2 SQL: "+err.message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var databaseOutput = function(s) {
|
||||
var el = document.getElementById("database_results");
|
||||
el.innerHTML = el.innerHTML + s + "<br>";
|
||||
};
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>HTML5 Database</h1>
|
||||
<div id="info">
|
||||
<b>Results:</b><br>
|
||||
<span id="database_results"></span>
|
||||
</div>
|
||||
<h2>Action</h2>
|
||||
<a href="javascript:" class="btn large" onclick="callDatabase();">Create, Add, Read Database</a>
|
||||
<a href="javascript:" class="btn large" onclick="readDatabase();">Read Database</a>
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
@ -1,50 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../phonegap.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>Local Storage</h1>
|
||||
<div id="info">
|
||||
You have run this app <span id="count">an untold number of</span> time(s).
|
||||
</div>
|
||||
|
||||
<script>
|
||||
if (!localStorage.pageLoadCount) {
|
||||
localStorage.pageLoadCount = 0;
|
||||
}
|
||||
localStorage.pageLoadCount = parseInt(localStorage.pageLoadCount) + 1;
|
||||
document.getElementById('count').textContent = localStorage.pageLoadCount;
|
||||
</script>
|
||||
|
||||
<h2> </h2><a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
|
||||
</body>
|
||||
</html>
|
@ -1,35 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>PhoneGap</title>
|
||||
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
<h1>PhoneGap Tests</h1>
|
||||
<div id="info">
|
||||
<h4>Platform: <span id="platform"> </span></h4>
|
||||
<h4>Version: <span id="version"> </span></h4>
|
||||
<h4>UUID: <span id="uuid"> </span></h4>
|
||||
<h4>Name: <span id="name"> </span></h4>
|
||||
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||
</div>
|
||||
<a href="autotest/index.html" class="btn large">Automatic Test</a>
|
||||
<a href="accelerometer/index.html" class="btn large">Accelerometer</a>
|
||||
<a href="audio/index.html" class="btn large">Audio Play/Record</a>
|
||||
<a href="camera/index.html" class="btn large">Camera</a>
|
||||
<a href="compass/index.html" class="btn large">Compass</a>
|
||||
<a href="contacts/index.html" class="btn large">Contacts</a>
|
||||
<a href="events/index.html" class="btn large">Events</a>
|
||||
<a href="location/index.html" class="btn large">Location</a>
|
||||
<a href="misc/index.html" class="btn large">Misc Content</a>
|
||||
<a href="notification/index.html" class="btn large">Notification</a>
|
||||
<a href="sql/index.html" class="btn large">Web SQL</a>
|
||||
<a href="storage/index.html" class="btn large">Local Storage</a>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user