cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject [1/2] cordova-plugin-camera git commit: CB-11447 Resolve iOS tests failures due to iOS quirks
Date Thu, 28 Jul 2016 13:57:53 GMT
Repository: cordova-plugin-camera
Updated Branches:
  refs/heads/master 7129fb2c1 -> fed798e6c


CB-11447 Resolve iOS tests failures due to iOS quirks

* Skip image type verification if source is gallery
  and destination is native uri
* Update docs t oclarify how camera works on iOS in
  some edge cases


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/2027d696
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/2027d696
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/2027d696

Branch: refs/heads/master
Commit: 2027d696062cd50972ba4dd0a26cd5b01ad2f413
Parents: 7129fb2
Author: Vladimir Kotikov <kotikov.vladimir@gmail.com>
Authored: Tue Jul 26 11:15:26 2016 +0300
Committer: Vladimir Kotikov <kotikov.vladimir@gmail.com>
Committed: Tue Jul 26 15:59:49 2016 +0300

----------------------------------------------------------------------
 README.md                            | 16 +++++++++++++---
 appium-tests/helpers/cameraHelper.js | 13 +++++++++++--
 appium-tests/ios/ios.spec.js         | 24 ++++++++++++------------
 jsdoc2md/TEMPLATE.md                 |  2 ++
 www/Camera.js                        |  3 ---
 www/CameraConstants.js               | 13 +++++++++++++
 6 files changed, 51 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/2027d696/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 0258903..391b5cf 100644
--- a/README.md
+++ b/README.md
@@ -126,16 +126,13 @@ one of the following formats, depending on the specified
 `cameraOptions`:
 
 - A `String` containing the Base64-encoded photo image.
-
 - A `String` representing the image file location on local storage (default).
 
 You can do whatever you want with the encoded image or URI, for
 example:
 
 - Render the image in an `<img>` tag, as in the example below
-
 - Save the data locally (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/),
etc.)
-
 - Post the data to a remote server
 
 __NOTE__: Photo resolution on newer devices is quite good. Photos
@@ -258,6 +255,12 @@ Optional parameters to customize the camera settings.
 <a name="module_Camera.DestinationType"></a>
 
 ### Camera.DestinationType : <code>enum</code>
+Defines the output format of `Camera.getPicture` call.
+_Note:_ On iOS passing `DestinationType.NATIVE_URI` along with
+`PictureSourceType.PHOTOLIBRARY` or `PictureSourceType.SAVEDPHOTOALBUM` will
+disable any image modifications (resize, quality change, cropping, etc.) due
+to implementation specific.
+
 **Kind**: static enum property of <code>[Camera](#module_Camera)</code>  
 **Properties**
 
@@ -293,6 +296,11 @@ Optional parameters to customize the camera settings.
 <a name="module_Camera.PictureSourceType"></a>
 
 ### Camera.PictureSourceType : <code>enum</code>
+Defines the output format of `Camera.getPicture` call.
+_Note:_ On iOS passing `PictureSourceType.PHOTOLIBRARY` or `PictureSourceType.SAVEDPHOTOALBUM`
+along with `DestinationType.NATIVE_URI` will disable any image modifications (resize, quality
+change, cropping, etc.) due to implementation specific.
+
 **Kind**: static enum property of <code>[Camera](#module_Camera)</code>  
 **Properties**
 
@@ -531,6 +539,8 @@ Tizen only supports a `destinationType` of
 
 - When using `destinationType.NATIVE_URI` and `sourceType.CAMERA`, photos are saved in the
saved photo album regardless on the value of `saveToPhotoAlbum` parameter.
 
+- When using `destinationType.NATIVE_URI` and `sourceType.PHOTOLIBRARY` or `sourceType.SAVEDPHOTOALBUM`,
all editing options are ignored and link is returned to original picture.
+
 #### Tizen Quirks
 
 - options not supported

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/2027d696/appium-tests/helpers/cameraHelper.js
----------------------------------------------------------------------
diff --git a/appium-tests/helpers/cameraHelper.js b/appium-tests/helpers/cameraHelper.js
index 5f60bc3..00578a9 100644
--- a/appium-tests/helpers/cameraHelper.js
+++ b/appium-tests/helpers/cameraHelper.js
@@ -119,10 +119,19 @@ module.exports.checkPicture = function (pid, options, cb) {
     var isAndroid = cordova.platformId === "android";
     // skip image type check if it's unmodified on Android:
     // https://github.com/apache/cordova-plugin-camera/#android-quirks-1
-    var skipFileTypeCheck = isAndroid &&
-        options.quality === 100 &&
+    var skipFileTypeCheckAndroid = isAndroid && options.quality === 100 &&
         !options.targetWidth && !options.targetHeight &&
         !options.correctOrientation;
+
+    // Skip image type check if destination is NATIVE_URI and source - device's photoalbum
+    // https://github.com/apache/cordova-plugin-camera/#ios-quirks-1
+    // TODO: correct link above
+    var skipFileTypeCheckiOS = isIos && options.destinationType === Camera.DestinationType.NATIVE_URI
&&
+        (options.sourceType === Camera.PictureSourceType.PHOTOLIBRARY ||
+         options.sourceType === Camera.PictureSourceType.SAVEDPHOTOALBUM);
+
+    var skipFileTypeCheck = skipFileTypeCheckAndroid || skipFileTypeCheckiOS;
+
     var desiredType = 'JPEG';
     var mimeType = 'image/jpeg';
     if (options.encodingType === Camera.EncodingType.PNG) {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/2027d696/appium-tests/ios/ios.spec.js
----------------------------------------------------------------------
diff --git a/appium-tests/ios/ios.spec.js b/appium-tests/ios/ios.spec.js
index 224190e..af12fd8 100644
--- a/appium-tests/ios/ios.spec.js
+++ b/appium-tests/ios/ios.spec.js
@@ -286,7 +286,7 @@ describe('Camera tests iOS.', function () {
             runSpec(options).done(done);
         }, 3 * MINUTE);
 
-        it('camera.ui.spec.6 Verifying target image size, sourceType=CAMERA, destinationType=NATIVE_URI',
function (done) {
+        it('camera.ui.spec.6 Verifying target image size, sourceType=CAMERA, destinationType=FILE_URL',
function (done) {
             // remove this line if you don't mind the tests leaving a photo saved on device
             pending('Cannot prevent iOS from saving the picture to photo library');
 
@@ -298,7 +298,7 @@ describe('Camera tests iOS.', function () {
                 quality: 50,
                 allowEdit: false,
                 sourceType: cameraConstants.PictureSourceType.CAMERA,
-                destinationType: cameraConstants.DestinationType.NATIVE_URI,
+                destinationType: cameraConstants.DestinationType.FILE_URL,
                 saveToPhotoAlbum: false,
                 targetWidth: 210,
                 targetHeight: 210
@@ -307,13 +307,13 @@ describe('Camera tests iOS.', function () {
             runSpec(options).done(done);
         }, 3 * MINUTE);
 
-        it('camera.ui.spec.7 Verifying target image size, sourceType=SAVEDPHOTOALBUM, destinationType=NATIVE_URI',
function (done) {
+        it('camera.ui.spec.7 Verifying target image size, sourceType=SAVEDPHOTOALBUM, destinationType=FILE_URL',
function (done) {
             checkSession(done);
             var options = {
                 quality: 50,
                 allowEdit: false,
                 sourceType: cameraConstants.PictureSourceType.SAVEDPHOTOALBUM,
-                destinationType: cameraConstants.DestinationType.NATIVE_URI,
+                destinationType: cameraConstants.DestinationType.FILE_URL,
                 saveToPhotoAlbum: false,
                 targetWidth: 210,
                 targetHeight: 210
@@ -322,13 +322,13 @@ describe('Camera tests iOS.', function () {
             runSpec(options).done(done);
         }, 3 * MINUTE);
 
-        it('camera.ui.spec.8 Verifying target image size, sourceType=PHOTOLIBRARY, destinationType=NATIVE_URI',
function (done) {
+        it('camera.ui.spec.8 Verifying target image size, sourceType=PHOTOLIBRARY, destinationType=FILE_URL',
function (done) {
             checkSession(done);
             var options = {
                 quality: 50,
                 allowEdit: false,
                 sourceType: cameraConstants.PictureSourceType.PHOTOLIBRARY,
-                destinationType: cameraConstants.DestinationType.NATIVE_URI,
+                destinationType: cameraConstants.DestinationType.FILE_URL,
                 saveToPhotoAlbum: false,
                 targetWidth: 210,
                 targetHeight: 210
@@ -337,7 +337,7 @@ describe('Camera tests iOS.', function () {
             runSpec(options).done(done);
         }, 3 * MINUTE);
 
-        it('camera.ui.spec.9 Verifying target image size, sourceType=CAMERA, destinationType=NATIVE_URI,
quality=100', function (done) {
+        it('camera.ui.spec.9 Verifying target image size, sourceType=CAMERA, destinationType=FILE_URL,
quality=100', function (done) {
             // remove this line if you don't mind the tests leaving a photo saved on device
             pending('Cannot prevent iOS from saving the picture to photo library');
 
@@ -349,7 +349,7 @@ describe('Camera tests iOS.', function () {
                 quality: 100,
                 allowEdit: false,
                 sourceType: cameraConstants.PictureSourceType.CAMERA,
-                destinationType: cameraConstants.DestinationType.NATIVE_URI,
+                destinationType: cameraConstants.DestinationType.FILE_URL,
                 saveToPhotoAlbum: false,
                 targetWidth: 305,
                 targetHeight: 305
@@ -357,13 +357,13 @@ describe('Camera tests iOS.', function () {
             runSpec(options).done(done);
         }, 3 * MINUTE);
 
-        it('camera.ui.spec.10 Verifying target image size, sourceType=SAVEDPHOTOALBUM, destinationType=NATIVE_URI,
quality=100', function (done) {
+        it('camera.ui.spec.10 Verifying target image size, sourceType=SAVEDPHOTOALBUM, destinationType=FILE_URL,
quality=100', function (done) {
             checkSession(done);
             var options = {
                 quality: 100,
                 allowEdit: false,
                 sourceType: cameraConstants.PictureSourceType.SAVEDPHOTOALBUM,
-                destinationType: cameraConstants.DestinationType.NATIVE_URI,
+                destinationType: cameraConstants.DestinationType.FILE_URL,
                 saveToPhotoAlbum: false,
                 targetWidth: 305,
                 targetHeight: 305
@@ -372,13 +372,13 @@ describe('Camera tests iOS.', function () {
             runSpec(options).done(done);
         }, 3 * MINUTE);
 
-        it('camera.ui.spec.11 Verifying target image size, sourceType=PHOTOLIBRARY, destinationType=NATIVE_URI,
quality=100', function (done) {
+        it('camera.ui.spec.11 Verifying target image size, sourceType=PHOTOLIBRARY, destinationType=FILE_URL,
quality=100', function (done) {
             checkSession(done);
             var options = {
                 quality: 100,
                 allowEdit: false,
                 sourceType: cameraConstants.PictureSourceType.PHOTOLIBRARY,
-                destinationType: cameraConstants.DestinationType.NATIVE_URI,
+                destinationType: cameraConstants.DestinationType.FILE_URL,
                 saveToPhotoAlbum: false,
                 targetWidth: 305,
                 targetHeight: 305

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/2027d696/jsdoc2md/TEMPLATE.md
----------------------------------------------------------------------
diff --git a/jsdoc2md/TEMPLATE.md b/jsdoc2md/TEMPLATE.md
index 95ef23c..2e53a89 100644
--- a/jsdoc2md/TEMPLATE.md
+++ b/jsdoc2md/TEMPLATE.md
@@ -187,6 +187,8 @@ Tizen only supports a `destinationType` of
 
 - When using `destinationType.NATIVE_URI` and `sourceType.CAMERA`, photos are saved in the
saved photo album regardless on the value of `saveToPhotoAlbum` parameter.
 
+- When using `destinationType.NATIVE_URI` and `sourceType.PHOTOLIBRARY` or `sourceType.SAVEDPHOTOALBUM`,
all editing options are ignored and link is returned to original picture.
+
 #### Tizen Quirks
 
 - options not supported

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/2027d696/www/Camera.js
----------------------------------------------------------------------
diff --git a/www/Camera.js b/www/Camera.js
index 2f9154b..04d13d9 100644
--- a/www/Camera.js
+++ b/www/Camera.js
@@ -99,16 +99,13 @@ for (var key in Camera) {
  * `cameraOptions`:
  *
  * - A `String` containing the Base64-encoded photo image.
- *
  * - A `String` representing the image file location on local storage (default).
  *
  * You can do whatever you want with the encoded image or URI, for
  * example:
  *
  * - Render the image in an `<img>` tag, as in the example below
- *
  * - Save the data locally (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/),
etc.)
- *
  * - Post the data to a remote server
  *
  * __NOTE__: Photo resolution on newer devices is quite good. Photos

http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/2027d696/www/CameraConstants.js
----------------------------------------------------------------------
diff --git a/www/CameraConstants.js b/www/CameraConstants.js
index f4b0694..c13dba3 100644
--- a/www/CameraConstants.js
+++ b/www/CameraConstants.js
@@ -24,6 +24,13 @@
  */
 module.exports = {
   /**
+   * @description
+   * Defines the output format of `Camera.getPicture` call.
+   * _Note:_ On iOS passing `DestinationType.NATIVE_URI` along with
+   * `PictureSourceType.PHOTOLIBRARY` or `PictureSourceType.SAVEDPHOTOALBUM` will
+   * disable any image modifications (resize, quality change, cropping, etc.) due
+   * to implementation specific.
+   *
    * @enum {number}
    */
   DestinationType:{
@@ -55,6 +62,12 @@ module.exports = {
     ALLMEDIA : 2
   },
   /**
+   * @description
+   * Defines the output format of `Camera.getPicture` call.
+   * _Note:_ On iOS passing `PictureSourceType.PHOTOLIBRARY` or `PictureSourceType.SAVEDPHOTOALBUM`
+   * along with `DestinationType.NATIVE_URI` will disable any image modifications (resize,
quality
+   * change, cropping, etc.) due to implementation specific.
+   *
    * @enum {number}
    */
   PictureSourceType:{


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


Mime
View raw message