mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-03-03 21:32:53 +08:00
CB-11147 Appium tests: generate descriptive spec names
This commit is contained in:
parent
bfaef0ff25
commit
68e18a97d1
@ -78,18 +78,13 @@ describe('Camera tests Android.', function () {
|
||||
var sourceTypes = [
|
||||
cameraConstants.PictureSourceType.CAMERA,
|
||||
cameraConstants.PictureSourceType.PHOTOLIBRARY
|
||||
],
|
||||
destinationTypes = cameraConstants.DestinationType,
|
||||
encodingTypes = [
|
||||
cameraConstants.EncodingType.JPEG,
|
||||
cameraConstants.EncodingType.PNG
|
||||
],
|
||||
allowEditOptions = [
|
||||
true,
|
||||
false
|
||||
];
|
||||
var destinationTypes = cameraConstants.DestinationType;
|
||||
var encodingTypes = cameraConstants.EncodingType;
|
||||
var allowEditOptions = [ true, false ];
|
||||
var correctOrientationOptions = [ true, false ];
|
||||
|
||||
return cameraHelper.generateSpecs(sourceTypes, destinationTypes, encodingTypes, allowEditOptions);
|
||||
return cameraHelper.generateSpecs(sourceTypes, destinationTypes, encodingTypes, allowEditOptions, correctOrientationOptions);
|
||||
}
|
||||
|
||||
// invokes Camera.getPicture() with the specified options
|
||||
@ -373,7 +368,7 @@ describe('Camera tests Android.', function () {
|
||||
|
||||
// combine various options for getPicture()
|
||||
generateSpecs().forEach(function (spec) {
|
||||
it('camera.ui.spec.5.' + spec.id + ' Combining options', function (done) {
|
||||
it('camera.ui.spec.5.' + spec.id + ' Combining options. ' + spec.description, function (done) {
|
||||
runCombinedSpec(spec)
|
||||
.done(done);
|
||||
}, 3 * MINUTE);
|
||||
|
@ -25,11 +25,35 @@
|
||||
|
||||
var cameraConstants = require('../../www/CameraConstants');
|
||||
|
||||
module.exports.generateSpecs = function (sourceTypes, destinationTypes, encodingTypes, allowEditOptions) {
|
||||
function findKeyByValue(set, value) {
|
||||
for (var k in set) {
|
||||
if (set.hasOwnProperty(k)) {
|
||||
if (set[k] == value) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getDescription(spec) {
|
||||
var desc = '';
|
||||
|
||||
desc += 'sourceType: ' + findKeyByValue(cameraConstants.PictureSourceType, spec.options.sourceType);
|
||||
desc += ', destinationType: ' + findKeyByValue(cameraConstants.DestinationType, spec.options.destinationType);
|
||||
desc += ', encodingType: ' + findKeyByValue(cameraConstants.EncodingType, spec.options.encodingType);
|
||||
desc += ', allowEdit: ' + spec.options.allowEdit.toString();
|
||||
desc += ', correctOrientation: ' + spec.options.correctOrientation.toString();
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
module.exports.generateSpecs = function (sourceTypes, destinationTypes, encodingTypes, allowEditOptions, correctOrientationOptions) {
|
||||
var destinationType,
|
||||
sourceType,
|
||||
encodingType,
|
||||
allowEdit,
|
||||
correctOrientation,
|
||||
specs = [],
|
||||
id = 1;
|
||||
for (destinationType in destinationTypes) {
|
||||
@ -40,9 +64,12 @@ module.exports.generateSpecs = function (sourceTypes, destinationTypes, encoding
|
||||
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({
|
||||
for (correctOrientation in correctOrientationOptions) {
|
||||
// if taking picture from photolibrary, don't vary 'correctOrientation' option
|
||||
if ((sourceTypes[sourceType] === cameraConstants.PictureSourceType.PHOTOLIBRARY ||
|
||||
sourceTypes[sourceType] === cameraConstants.PictureSourceType.SAVEDPHOTOALBUM) &&
|
||||
correctOrientation === true) { continue; }
|
||||
var spec = {
|
||||
'id': id++,
|
||||
'options': {
|
||||
'destinationType': destinationTypes[destinationType],
|
||||
@ -50,30 +77,11 @@ module.exports.generateSpecs = function (sourceTypes, destinationTypes, encoding
|
||||
'encodingType': encodingTypes[encodingType],
|
||||
'allowEdit': allowEditOptions[allowEdit],
|
||||
'saveToPhotoAlbum': false,
|
||||
'correctOrientation': correctOrientationOptions[correctOrientation]
|
||||
}
|
||||
});
|
||||
} 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,
|
||||
}
|
||||
});
|
||||
};
|
||||
spec.description = getDescription(spec);
|
||||
specs.push(spec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,21 +67,13 @@ describe('Camera tests iOS.', function () {
|
||||
// generates test specs by combining all the specified options
|
||||
// you can add more options to test more scenarios
|
||||
function generateSpecs() {
|
||||
var sourceTypes = [
|
||||
cameraConstants.PictureSourceType.CAMERA,
|
||||
cameraConstants.PictureSourceType.PHOTOLIBRARY
|
||||
],
|
||||
destinationTypes = cameraConstants.DestinationType,
|
||||
encodingTypes = [
|
||||
cameraConstants.EncodingType.JPEG,
|
||||
cameraConstants.EncodingType.PNG
|
||||
],
|
||||
allowEditOptions = [
|
||||
true,
|
||||
false
|
||||
];
|
||||
var sourceTypes = cameraConstants.PictureSourceType;
|
||||
var destinationTypes = cameraConstants.DestinationType;
|
||||
var encodingTypes = cameraConstants.EncodingType;
|
||||
var allowEditOptions = [ true, false ];
|
||||
var correctOrientationOptions = [ true, false ];
|
||||
|
||||
return cameraHelper.generateSpecs(sourceTypes, destinationTypes, encodingTypes, allowEditOptions);
|
||||
return cameraHelper.generateSpecs(sourceTypes, destinationTypes, encodingTypes, allowEditOptions, correctOrientationOptions);
|
||||
}
|
||||
|
||||
function usePicture() {
|
||||
@ -245,7 +237,7 @@ describe('Camera tests iOS.', function () {
|
||||
|
||||
// combine various options for getPicture()
|
||||
generateSpecs().forEach(function (spec) {
|
||||
it('camera.ui.spec.3.' + spec.id + ' Combining options', function (done) {
|
||||
it('camera.ui.spec.3.' + spec.id + ' Combining options. ' + spec.description, function (done) {
|
||||
// camera is not available on iOS simulator
|
||||
if (!isDevice && spec.options.sourceType === cameraConstants.PictureSourceType.CAMERA) {
|
||||
pending();
|
||||
|
Loading…
Reference in New Issue
Block a user