Commit bcf17ef9 authored by sgrebnov's avatar sgrebnov
Browse files

CB-8428 Fix tests on Windows if no audio playback hardware is available

parent fb45b2a0
Loading
Loading
Loading
Loading
+6 −2
Changes for src/windows/MediaProxy.js: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -96,8 +96,12 @@ module.exports = {
    stopPlayingAudio:function(win, lose, args) {
        var id = args[0];
        try {
            (Media.get(id)).node.pause();
            (Media.get(id)).node.currentTime = 0;
            var thisM = Media.get(id);
            thisM.node.pause();
            if (thisM.node.currentTime != 0) {
                // prevents failing w/ InvalidStateError if playback has not started
                thisM.node.currentTime = 0;
            }
            Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED);
            win();
        } catch (err) {
+14 −0
Changes for tests/tests.js: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -19,6 +19,10 @@
 *
 */
 
var isWindows = cordova.platformId == 'windows8' || cordova.platformId == 'windows';
// detect whether audio hardware is available and enabled
var isAudioSupported = isWindows ? Windows.Media.Devices.MediaDevice.getDefaultAudioRenderId(Windows.Media.Devices.AudioDeviceRole.default) : true;

exports.defineAutoTests = function () {
    var failed = function (done, msg, error) {
        var info = typeof msg == 'undefined' ? 'Unexpected error callback' : msg;
@@ -180,6 +184,11 @@ exports.defineAutoTests = function () {
        });

        it("media.spec.16 position should be set properly", function (done) {
            // no audio hardware available
            if (!isAudioSupported) {
                pending();
                return;
            }
            var self = this;
            var mediaFile = 'http://cordova.apache.org/downloads/BlueZedEx.mp3',
            mediaState = Media.MEDIA_STOPPED,
@@ -208,6 +217,11 @@ exports.defineAutoTests = function () {
        });

        it("media.spec.17 duration should be set properly", function (done) {
            // no audio hardware available
            if (!isAudioSupported) {
                pending();
                return;
            }
            var self = this;
            if (cordova.platformId === 'blackberry10') {
                expect(true).toFailWithMessage('Platform does not supported this feature');