CB-6963 Removed old media tests
diff --git a/www/audio/index.html b/www/audio/index.html
deleted file mode 100644
index a05ea04..0000000
--- a/www/audio/index.html
+++ /dev/null
@@ -1,88 +0,0 @@
-<!DOCTYPE html>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-
-
-<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>Cordova Audio Tests</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="../cordova-incl.js"></script>
- <script type="text/javascript" charset="utf-8" src="./index.js"></script>
-
- </head>
- <body 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>
- <table style="width:80%;">
- <tr>
- <th colspan=3>Play Sample Audio</th>
- </tr>
- <tr>
- <td><div class="btn wide playAudio">Play</div></td>
- <td><div class="btn wide pauseAudio">Pause</div></td>
- </tr>
- <tr>
- <td><div class="btn wide stopAudio">Stop</div></td>
- <td><div class="btn wide releaseAudio">Release</div></td>
- </tr>
- </table>
-
- <table style="width:80%;">
- <tr>
- <td><div class="btn wide seekAudioBy">Seek By</div></td>
- <td><div class="btn wide seekAudioTo">Seek To</div></td>
- <td>
- <div>
- <input class="input numeric" type="number" id="seekinput" value="in seconds">
- </div>
- </td>
- </tr>
- </table>
-
- <table style="width:80%;">
- <tr>
- <th colspan=3><br><br>Record Audio</th>
- </tr>
- <tr>
- <td colspan=3><div class="btn wide recordAudio">Record Audio for 10 sec</a></td>
- </tr>
- <tr>
- <td><div class="btn wide playRecording">Play</div></td>
- <td><div class="btn wide pauseAudio">Pause</div></td>
- <td><div class="btn wide stopAudio">Stop</div></td>
- </tr>
- </table>
-
- <h2> </h2><div class="backBtn">Back</div>
-
- </body>
-</html>
diff --git a/www/audio/index.js b/www/audio/index.js
deleted file mode 100644
index e7ca9b6..0000000
--- a/www/audio/index.js
+++ /dev/null
@@ -1,356 +0,0 @@
-var defaultaudio = "http://cordova.apache.org/downloads/BlueZedEx.mp3";
-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 = defaultaudio;
-
- 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.code);
- setAudioStatus("Error: " + err.code);
- },
- 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;
- setAudioPosition("0 sec");
- }
- });
- }
- 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 >= 0.0) {
- 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;
-}
-
-/**
- * Release audio
- */
-function releaseAudio() {
- console.log("releaseAudio()");
- if (media1) {
- media1.stop(); //imlied stop of playback, resets timer
- media1.release();
- }
-}
-
-
-/**
- * Set audio status
- */
-function setAudioStatus(status) {
- document.getElementById('audio_status').innerHTML = status;
-};
-
-/**
- * Set audio position
- */
-function setAudioPosition(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.code);
- setAudioStatus("Error: " + err.code);
- },
- 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 to create a file for BB recording
- */
-function getRecordSrcBB() {
- var fsFail = function(error) {
- console.log("error creating file for BB recording");
- };
- var gotFile = function(file) {
- recordSrc = file.fullPath;
- };
- var gotFS = function(fileSystem) {
- fileSystem.root.getFile("BBRecording.amr", {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("iOS") !=-1)
- {
- getRecordSrc();
- } else if (typeof blackberry !== 'undefined') {
- getRecordSrcBB();
- }
- console.log("Device="+device.platform+" "+device.version);
- }, false);
- window.setTimeout(function() {
- if (!deviceReady) {
- alert("Error: Apache Cordova did not initialize. Demo will not run correctly.");
- }
- },1000);
-}
-
-/**
- * for forced updates of position after a successful seek
- */
-function updatePosition() {
- media1.getCurrentPosition(
- function(position) {
- console.log("Pos="+position);
- if (position >= 0.0) {
- setAudioPosition(position+" sec");
- }
- },
- function(e) {
- console.log("Error getting pos="+e);
- setAudioPosition("Error: "+e);
- });
-}
-
-/**
- *
- */
-function seekAudio(mode) {
- var time = document.getElementById("seekinput").value;
- if (time == "") {
- time = 5000;
- } else {
- time = time * 1000; //we expect the input to be in seconds
- }
- if (media1 == null) {
- console.log("seekTo requested while media1 is null");
- if (audioSrc == null) {
- audioSrc = defaultaudio;
- }
- media1 = new Media(audioSrc,
- function() {
- console.log("seekToAudio():Audio Success");
- },
- function(err) {
- console.log("seekAudio():Audio Error: "+err.code);
- setAudioStatus("Error: " + err.code);
- },
- function(status) {
- console.log("seekAudio():Audio Status: "+status);
- setAudioStatus(Media.MEDIA_MSG[status]);
-
- // If stopped, then stop getting current position
- if (Media.MEDIA_STOPPED == status) {
- clearInterval(media1Timer);
- media1Timer = null;
- setAudioPosition("0 sec");
- }
- });
- }
-
- media1.getCurrentPosition(
- function (position) {
- var deltat = time;
- if (mode == "by") {
- deltat = time + position * 1000;
- }
- media1.seekTo(deltat,
- function () {
- console.log("seekAudioTo():Audio Success");
- //force an update on the position display
- updatePosition();
- },
- function (err) {
- console.log("seekAudioTo():Audio Error: " + err.code);
- });
- },
- function(e) {
- console.log("Error getting pos="+e);
- setAudioPosition("Error: "+e);
- });
-}
-
-window.onload = function() {
- addListenerToClass('playAudio', function () {
- playAudio();
- });
- addListenerToClass('pauseAudio', pauseAudio);
- addListenerToClass('stopAudio', stopAudio);
- addListenerToClass('releaseAudio', releaseAudio);
- addListenerToClass('seekAudioBy', seekAudio, 'by');
- addListenerToClass('seekAudioTo', seekAudio, 'to');
- addListenerToClass('recordAudio', recordAudio);
- addListenerToClass('playRecording', playRecording);
-
- addListenerToClass('backBtn', backHome);
- init();
-}
diff --git a/www/autotest/index.html b/www/autotest/index.html
index fe1dd91..f9c2279 100644
--- a/www/autotest/index.html
+++ b/www/autotest/index.html
@@ -47,7 +47,6 @@
<a href="pages/filetransfer.html" class="btn large" style="width:100%;">Run FileTransfer Tests</a>
<a href="pages/geolocation.html" class="btn large" style="width:100%;">Run Geolocation Tests</a>
<a href="pages/globalization.html" class="btn large" style="width:100%;">Run Globalization Tests</a>
- <a href="pages/media.html" class="btn large" style="width:100%;">Run Media Tests</a>
<a href="pages/network.html" class="btn large" style="width:100%;">Run Network Tests</a>
<a href="pages/notification.html" class="btn large" style="width:100%;">Run Notification Tests</a>
<a href="pages/platform.html" class="btn large" style="width:100%;">Run Platform Tests</a>
diff --git a/www/autotest/pages/all.html b/www/autotest/pages/all.html
index 9ee9180..7c0d0bc 100644
--- a/www/autotest/pages/all.html
+++ b/www/autotest/pages/all.html
@@ -56,7 +56,6 @@
<script type="text/javascript" src="../tests/filetransfer.tests.js"></script>
<script type="text/javascript" src="../tests/geolocation.tests.js"></script>
<script type="text/javascript" src="../tests/globalization.tests.js"></script>
- <script type="text/javascript" src="../tests/media.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/platform.tests.js"></script>
diff --git a/www/autotest/pages/media.html b/www/autotest/pages/media.html
deleted file mode 100644
index ac1fa75..0000000
--- a/www/autotest/pages/media.html
+++ /dev/null
@@ -1,55 +0,0 @@
-<!DOCTYPE html>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-
-
-<html>
-
-<head>
- <title>Cordova: Media API Specs</title>
-
- <meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes, initial-scale=1.0;" />
- <!-- Load jasmine -->
- <link href="../jasmine.css" rel="stylesheet"/>
- <script type="text/javascript" src="../jasmine.js"></script>
- <script type="text/javascript" src="../html/HtmlReporterHelpers.js"></script>
- <script type="text/javascript" src="../html/HtmlReporter.js"></script>
- <script type="text/javascript" src="../html/ReporterView.js"></script>
- <script type="text/javascript" src="../html/SpecView.js"></script>
- <script type="text/javascript" src="../html/SuiteView.js"></script>
- <script type="text/javascript" src="../html/TrivialReporter.js"></script>
-
- <!-- Source -->
- <script type="text/javascript" src="../../cordova-incl.js"></script>
-
- <!-- Load Test Runner -->
- <script type="text/javascript" src="../test-runner.js"></script>
-
- <!-- Tests -->
- <script type="text/javascript" src="../tests/media.tests.js"></script>
- <script type="text/javascript" charset="utf-8" src="./run-tests.js"></script>
-</head>
-
-<body>
- <a href="javascript:" class="backBtn">Back</a>
-</body>
-</html>
-
diff --git a/www/autotest/tests/media.tests.js b/www/autotest/tests/media.tests.js
deleted file mode 100644
index 393ca00..0000000
--- a/www/autotest/tests/media.tests.js
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-describe('Media', function () {
- it("should exist", function() {
- expect(Media).toBeDefined();
- expect(typeof Media).toBe("function");
- });
-
- it("media.spec.1 should have the following properties", function() {
- var media1 = new Media("dummy");
- expect(media1.id).toBeDefined();
- expect(media1.src).toBeDefined();
- expect(media1._duration).toBeDefined();
- expect(media1._position).toBeDefined();
- media1.release();
- });
-
- it("should define constants for Media status", function() {
- expect(Media).toBeDefined();
- expect(Media.MEDIA_NONE).toBe(0);
- expect(Media.MEDIA_STARTING).toBe(1);
- expect(Media.MEDIA_RUNNING).toBe(2);
- expect(Media.MEDIA_PAUSED).toBe(3);
- expect(Media.MEDIA_STOPPED).toBe(4);
- });
-
- it("should define constants for Media errors", function() {
- expect(MediaError).toBeDefined();
- expect(MediaError.MEDIA_ERR_NONE_ACTIVE).toBe(0);
- expect(MediaError.MEDIA_ERR_ABORTED).toBe(1);
- expect(MediaError.MEDIA_ERR_NETWORK).toBe(2);
- expect(MediaError.MEDIA_ERR_DECODE).toBe(3);
- expect(MediaError.MEDIA_ERR_NONE_SUPPORTED).toBe(4);
- });
-
- it("media.spec.2 should contain a play function", function() {
- var media1 = new Media();
- expect(media1.play).toBeDefined();
- expect(typeof media1.play).toBe('function');
- media1.release();
- });
-
- it("media.spec.3 should contain a stop function", function() {
- var media1 = new Media();
- expect(media1.stop).toBeDefined();
- expect(typeof media1.stop).toBe('function');
- media1.release();
- });
-
- it("media.spec.4 should contain a seekTo function", function() {
- var media1 = new Media();
- expect(media1.seekTo).toBeDefined();
- expect(typeof media1.seekTo).toBe('function');
- media1.release();
- });
-
- it("media.spec.5 should contain a pause function", function() {
- var media1 = new Media();
- expect(media1.pause).toBeDefined();
- expect(typeof media1.pause).toBe('function');
- media1.release();
- });
-
- it("media.spec.6 should contain a getDuration function", function() {
- var media1 = new Media();
- expect(media1.getDuration).toBeDefined();
- expect(typeof media1.getDuration).toBe('function');
- media1.release();
- });
-
- it("media.spec.7 should contain a getCurrentPosition function", function() {
- var media1 = new Media();
- expect(media1.getCurrentPosition).toBeDefined();
- expect(typeof media1.getCurrentPosition).toBe('function');
- media1.release();
- });
-
- it("media.spec.8 should contain a startRecord function", function() {
- var media1 = new Media();
- expect(media1.startRecord).toBeDefined();
- expect(typeof media1.startRecord).toBe('function');
- media1.release();
- });
-
- it("media.spec.9 should contain a stopRecord function", function() {
- var media1 = new Media();
- expect(media1.stopRecord).toBeDefined();
- expect(typeof media1.stopRecord).toBe('function');
- media1.release();
- });
-
- it("media.spec.10 should contain a release function", function() {
- var media1 = new Media();
- expect(media1.release).toBeDefined();
- expect(typeof media1.release).toBe('function');
- media1.release();
- });
-
- it("media.spec.11 should contain a setVolume function", function() {
- var media1 = new Media();
- expect(media1.setVolume).toBeDefined();
- expect(typeof media1.setVolume).toBe('function');
- media1.release();
- });
-
- it("should return MediaError for bad filename", function() {
- var badMedia = null,
- win = jasmine.createSpy(),
- fail = jasmine.createSpy().andCallFake(function (result) {
- expect(result).toBeDefined();
- expect(result.code).toBe(MediaError.MEDIA_ERR_ABORTED);
- });
-
- //bb10 dialog pops up, preventing tests from running
- if (cordova.platformId === 'blackberry10') {
- return;
- }
-
- runs(function () {
- badMedia = new Media("invalid.file.name", win,fail);
- badMedia.play();
- });
-
- waitsFor(function () { return fail.wasCalled; }, Tests.TEST_TIMEOUT);
-
- runs(function () {
- expect(win).not.toHaveBeenCalled();
- badMedia.release();
- });
- });
-
- it("media.spec.12 position should be set properly", function() {
- var playcomplete = jasmine.createSpy();
- var fail = jasmine.createSpy();
- var mediaState=Media.MEDIA_STOPPED;
- var statuschange= function(statusCode){
- mediaState=statusCode;
- };
- var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3",playcomplete,fail,statuschange),
- test = jasmine.createSpy().andCallFake(function(position) {
- console.log("position = " + position);
- expect(position).toBeGreaterThan(0.0);
- media1.stop()
- media1.release();
- });
-
- media1.play();
-
- if (cordova.platformId !== 'blackberry10') {
- waitsFor(function () { return mediaState==Media.MEDIA_RUNNING; }, 10000);
- } else {
- waits(5000);
- }
-
- // make sure we are at least one second into the file
- waits(1000);
- runs(function () {
- expect(fail).not.toHaveBeenCalled();
- // note that the file is about 60 seconds long and we kill the play almost immediately
- // as a result, the playcomplete should not happen
- expect(playcomplete).not.toHaveBeenCalled();
- media1.getCurrentPosition(test, function () {});
- });
-
- waitsFor(function () { return test.wasCalled || fail.wasCalled; }, Tests.TEST_TIMEOUT);
- });
-
- it("media.spec.13 duration should be set properly", function() {
-
- if (cordova.platformId === 'blackberry10') {
- return;
- }
-
- var win = jasmine.createSpy();
- var fail = jasmine.createSpy();
- var mediaState=Media.MEDIA_STOPPED;
- var statuschange= function(statusCode){
- mediaState=statusCode;
- };
- var media1 = new Media("http://cordova.apache.org/downloads/BlueZedEx.mp3",win,fail,statuschange);
- media1.play();
- waitsFor(function () { return mediaState==Media.MEDIA_RUNNING; }, 10000);
- runs(function () {
- expect(media1.getDuration()).toBeGreaterThan(0.0);
- expect(fail).not.toHaveBeenCalled();
- });
- });
-});
diff --git a/www/index.html b/www/index.html
index 39bc875..e9f2919 100644
--- a/www/index.html
+++ b/www/index.html
@@ -44,7 +44,6 @@
<a href="cdvtests/index.html?showBack" class="btn large">New-Style Tests</a>
<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="capture/index.html" class="btn large">Capture</a>