cordova-plugin-camera/appium-tests/helpers/cameraHelper.js
Alexander Sorokin c1948fc0d4 CB-10639 Appium tests: Added some timeouts,
Taking a screenshot on failure,
Retry taking a picture up to 3 times,
Try to restart the Appium session if it's lost
2016-02-24 16:44:29 +03:00

66 lines
3.5 KiB
JavaScript

/*jshint node: true */
'use strict';
var cameraConstants = require('../../www/CameraConstants');
module.exports.generateSpecs = function (sourceTypes, destinationTypes, encodingTypes, allowEditOptions) {
var destinationType,
sourceType,
encodingType,
allowEdit,
specs = [],
id = 1;
for (destinationType in destinationTypes) {
if (destinationTypes.hasOwnProperty(destinationType)) {
for (sourceType in sourceTypes) {
if (sourceTypes.hasOwnProperty(sourceType)) {
for (encodingType in encodingTypes) {
if (encodingTypes.hasOwnProperty(encodingType)) {
for (allowEdit in allowEditOptions) {
if (allowEditOptions.hasOwnProperty(allowEdit)) {
// if taking picture from photolibrary, don't vary 'correctOrientation' option
if (sourceTypes[sourceType] === cameraConstants.PictureSourceType.PHOTOLIBRARY) {
specs.push({
'id': id++,
'options': {
'destinationType': destinationTypes[destinationType],
'sourceType': sourceTypes[sourceType],
'encodingType': encodingTypes[encodingType],
'allowEdit': allowEditOptions[allowEdit],
'saveToPhotoAlbum': false,
}
});
} else {
specs.push({
'id': id++,
'options': {
'destinationType': destinationTypes[destinationType],
'sourceType': sourceTypes[sourceType],
'encodingType': encodingTypes[encodingType],
'correctOrientation': true,
'allowEdit': allowEditOptions[allowEdit],
'saveToPhotoAlbum': false,
}
}, {
'id': id++,
'options': {
'destinationType': destinationTypes[destinationType],
'sourceType': sourceTypes[sourceType],
'encodingType': encodingTypes[encodingType],
'correctOrientation': false,
'allowEdit': allowEditOptions[allowEdit],
'saveToPhotoAlbum': false,
}
});
}
}
}
}
}
}
}
}
}
return specs;
};