CB-11430 Skip audio playback tests on Saucelabs
This is a cherry-pick of particular commits from #102
aiming to resolve ios tests failures on Saucelabs
diff --git a/tests/tests.js b/tests/tests.js
index bcc29a4..cab2aa4 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -27,8 +27,11 @@
var ACTUAL_PLAYBACK_TEST_TIMEOUT = 2 * 60 * 1000;
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;
+// Detect whether audio hardware is available and enabled. For iOS playing audio is
+// not supported on emulators w/out sound device connected to host PC but (which is
+// the case for Sauce Labs emulators - see CB-11430)
+var isAudioSupported = isWindows ? !!Windows.Media.Devices.MediaDevice.getDefaultAudioRenderId(Windows.Media.Devices.AudioDeviceRole.default) :
+ cordova.platformId === 'ios' ? !window.SAUCELABS_ENV : true;
exports.defineAutoTests = function () {
var failed = function (done, msg, context) {
@@ -371,8 +374,13 @@
if (cordova.platformId !== 'ios') {
expect(true).toFailWithMessage('Platform does not supported this feature');
pending();
- return;
}
+
+ // no audio hardware available
+ if (!isAudioSupported) {
+ pending();
+ }
+
var mediaFile = 'https://cordova.apache.org/downloads/BlueZedEx.mp3',
successCallback,
context = this,