cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alsoro...@apache.org
Subject cordova-plugin-camera git commit: CB-11147 Appium tests: generate descriptive spec names
Date Tue, 26 Apr 2016 07:45:52 GMT
Repository: cordova-plugin-camera
Updated Branches:
  refs/heads/master bfaef0ff2 -> 68e18a97d


CB-11147 Appium tests: generate descriptive spec names


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/68e18a97
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/68e18a97
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/68e18a97

Branch: refs/heads/master
Commit: 68e18a97d15835049fbfcb7b4767edb67d4c9fb3
Parents: bfaef0f
Author: Alexander Sorokin <alexander.sorokin@akvelon.com>
Authored: Mon Apr 25 17:37:48 2016 +0300
Committer: Alexander Sorokin <alexander.sorokin@akvelon.com>
Committed: Tue Apr 26 10:32:08 2016 +0300

----------------------------------------------------------------------
 appium-tests/android/android.spec.js | 17 +++------
 appium-tests/helpers/cameraHelper.js | 62 +++++++++++++++++--------------
 appium-tests/ios/ios.spec.js         | 22 ++++-------
 3 files changed, 48 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/68e18a97/appium-tests/android/android.spec.js
----------------------------------------------------------------------
diff --git a/appium-tests/android/android.spec.js b/appium-tests/android/android.spec.js
index 772ce6e..7a9a71b 100644
--- a/appium-tests/android/android.spec.js
+++ b/appium-tests/android/android.spec.js
@@ -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);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/68e18a97/appium-tests/helpers/cameraHelper.js
----------------------------------------------------------------------
diff --git a/appium-tests/helpers/cameraHelper.js b/appium-tests/helpers/cameraHelper.js
index 8a746f3..4f33163 100644
--- a/appium-tests/helpers/cameraHelper.js
+++ b/appium-tests/helpers/cameraHelper.js
@@ -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,40 +64,24 @@ 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({
-                                            '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,
-                                            }
-                                        }, {
+                                    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],
                                                 'sourceType': sourceTypes[sourceType],
                                                 'encodingType': encodingTypes[encodingType],
-                                                'correctOrientation': false,
                                                 'allowEdit': allowEditOptions[allowEdit],
                                                 'saveToPhotoAlbum': false,
+                                                'correctOrientation': correctOrientationOptions[correctOrientation]
                                             }
-                                        });
+                                        };
+                                        spec.description = getDescription(spec);
+                                        specs.push(spec);
                                     }
                                 }
                             }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/68e18a97/appium-tests/ios/ios.spec.js
----------------------------------------------------------------------
diff --git a/appium-tests/ios/ios.spec.js b/appium-tests/ios/ios.spec.js
index 186bbd9..ea856a7 100644
--- a/appium-tests/ios/ios.spec.js
+++ b/appium-tests/ios/ios.spec.js
@@ -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();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message