diff --git a/src/ios/UIImage+CropScaleOrientation.h b/src/ios/UIImage+CropScaleOrientation.h
index 0f7fca5..31bc42f 100644
--- a/src/ios/UIImage+CropScaleOrientation.h
+++ b/src/ios/UIImage+CropScaleOrientation.h
@@ -23,6 +23,7 @@
- (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize;
- (UIImage*)imageCorrectedForCaptureOrientation;
+- (UIImage*)imageCorrectedForCaptureOrientation:(UIImageOrientation)imageOrientation;
- (UIImage*)imageByScalingNotCroppingForSize:(CGSize)targetSize;
@end
\ No newline at end of file
diff --git a/src/ios/UIImage+CropScaleOrientation.m b/src/ios/UIImage+CropScaleOrientation.m
index 3ab3ad5..a66a5d8 100644
--- a/src/ios/UIImage+CropScaleOrientation.m
+++ b/src/ios/UIImage+CropScaleOrientation.m
@@ -74,12 +74,12 @@
return newImage;
}
-- (UIImage*)imageCorrectedForCaptureOrientation
+- (UIImage*)imageCorrectedForCaptureOrientation:(UIImageOrientation)imageOrientation
{
float rotation_radians = 0;
bool perpendicular = false;
- switch ([self imageOrientation]) {
+ switch (imageOrientation) {
case UIImageOrientationUp :
rotation_radians = 0.0;
break;
@@ -124,6 +124,11 @@
return newImage;
}
+- (UIImage*)imageCorrectedForCaptureOrientation
+{
+ return [self imageCorrectedForCaptureOrientation:[self imageOrientation]];
+}
+
- (UIImage*)imageByScalingNotCroppingForSize:(CGSize)targetSize
{
UIImage* sourceImage = self;
diff --git a/tests/ios/.gitignore b/tests/ios/.gitignore
new file mode 100644
index 0000000..b512c09
--- /dev/null
+++ b/tests/ios/.gitignore
@@ -0,0 +1 @@
+node_modules
\ No newline at end of file
diff --git a/tests/ios/CDVCameraTest.xcworkspace/contents.xcworkspacedata b/tests/ios/CDVCameraTest.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..22fcf41
--- /dev/null
+++ b/tests/ios/CDVCameraTest.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/CDVCameraTest.xccheckout b/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/CDVCameraTest.xccheckout
new file mode 100644
index 0000000..c8a5605
--- /dev/null
+++ b/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/CDVCameraTest.xccheckout
@@ -0,0 +1,41 @@
+
+
+
+
+ IDESourceControlProjectFavoriteDictionaryKey
+
+ IDESourceControlProjectIdentifier
+ 6BE9AD73-1B9F-4362-98D7-DC631BEC6185
+ IDESourceControlProjectName
+ CDVCameraTest
+ IDESourceControlProjectOriginsDictionary
+
+ 729B5706E7BAF4E9EE7AEE3C003A08107411AB7C
+ github.com:shazron/cordova-plugin-camera.git
+
+ IDESourceControlProjectPath
+ tests/ios/CDVCameraTest.xcworkspace
+ IDESourceControlProjectRelativeInstallPathDictionary
+
+ 729B5706E7BAF4E9EE7AEE3C003A08107411AB7C
+ ../../..
+
+ IDESourceControlProjectURL
+ github.com:shazron/cordova-plugin-camera.git
+ IDESourceControlProjectVersion
+ 111
+ IDESourceControlProjectWCCIdentifier
+ 729B5706E7BAF4E9EE7AEE3C003A08107411AB7C
+ IDESourceControlProjectWCConfigurations
+
+
+ IDESourceControlRepositoryExtensionIdentifierKey
+ public.vcs.git
+ IDESourceControlWCCIdentifierKey
+ 729B5706E7BAF4E9EE7AEE3C003A08107411AB7C
+ IDESourceControlWCCName
+ cordova-plugin-camera
+
+
+
+
diff --git a/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/xcschemes/CordovaLib.xcscheme b/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/xcschemes/CordovaLib.xcscheme
new file mode 100644
index 0000000..3e8cd2c
--- /dev/null
+++ b/tests/ios/CDVCameraTest.xcworkspace/xcshareddata/xcschemes/CordovaLib.xcscheme
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/ios/CDVCameraTest/CDVCameraLibTests/CameraTest.m b/tests/ios/CDVCameraTest/CDVCameraLibTests/CameraTest.m
new file mode 100644
index 0000000..d0e8b4b
--- /dev/null
+++ b/tests/ios/CDVCameraTest/CDVCameraLibTests/CameraTest.m
@@ -0,0 +1,498 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import
+#import
+#import "CDVCamera.h"
+#import "UIImage+CropScaleOrientation.h"
+#import
+#import
+#import
+#import
+
+
+@interface CameraTest : XCTestCase
+
+@property (nonatomic, strong) CDVCamera* plugin;
+
+@end
+
+@interface CDVCamera ()
+
+// expose private interface
+- (NSData*)processImage:(UIImage*)image info:(NSDictionary*)info options:(CDVPictureOptions*)options;
+- (UIImage*)retrieveImage:(NSDictionary*)info options:(CDVPictureOptions*)options;
+- (CDVPluginResult*)resultForImage:(CDVPictureOptions*)options info:(NSDictionary*)info;
+- (CDVPluginResult*)resultForVideo:(NSDictionary*)info;
+
+@end
+
+@implementation CameraTest
+
+- (void)setUp {
+ [super setUp];
+ // Put setup code here. This method is called before the invocation of each test method in the class.
+
+ self.plugin = [[CDVCamera alloc] init];
+}
+
+- (void)tearDown {
+ // Put teardown code here. This method is called after the invocation of each test method in the class.
+ [super tearDown];
+}
+
+- (void) testPictureOptionsCreate
+{
+ NSArray* args;
+ CDVPictureOptions* options;
+ NSDictionary* popoverOptions;
+
+ // No arguments, check whether the defaults are set
+ args = @[];
+ options = [CDVPictureOptions createFromTakePictureArguments:args];
+
+ XCTAssertEqual([options.quality intValue], 50);
+ XCTAssertEqual(options.destinationType, (int)DestinationTypeFileUri);
+ XCTAssertEqual(options.sourceType, (int)UIImagePickerControllerSourceTypeCamera);
+ XCTAssertEqual(options.targetSize.width, 0);
+ XCTAssertEqual(options.targetSize.height, 0);
+ XCTAssertEqual(options.encodingType, (int)EncodingTypeJPEG);
+ XCTAssertEqual(options.mediaType, (int)MediaTypePicture);
+ XCTAssertEqual(options.allowsEditing, NO);
+ XCTAssertEqual(options.correctOrientation, NO);
+ XCTAssertEqual(options.saveToPhotoAlbum, NO);
+ XCTAssertEqualObjects(options.popoverOptions, nil);
+ XCTAssertEqual(options.cameraDirection, (int)UIImagePickerControllerCameraDeviceRear);
+ XCTAssertEqual(options.popoverSupported, NO);
+ XCTAssertEqual(options.usesGeolocation, NO);
+
+ // Set each argument, check whether they are set. different from defaults
+ popoverOptions = @{ @"x" : @1, @"y" : @2, @"width" : @3, @"height" : @4 };
+
+ args = @[
+ @(49),
+ @(DestinationTypeDataUrl),
+ @(UIImagePickerControllerSourceTypePhotoLibrary),
+ @(120),
+ @(240),
+ @(EncodingTypePNG),
+ @(MediaTypeVideo),
+ @YES,
+ @YES,
+ @YES,
+ popoverOptions,
+ @(UIImagePickerControllerCameraDeviceFront),
+ ];
+ options = [CDVPictureOptions createFromTakePictureArguments:args];
+
+ XCTAssertEqual([options.quality intValue], 49);
+ XCTAssertEqual(options.destinationType, (int)DestinationTypeDataUrl);
+ XCTAssertEqual(options.sourceType, (int)UIImagePickerControllerSourceTypePhotoLibrary);
+ XCTAssertEqual(options.targetSize.width, 120);
+ XCTAssertEqual(options.targetSize.height, 240);
+ XCTAssertEqual(options.encodingType, (int)EncodingTypePNG);
+ XCTAssertEqual(options.mediaType, (int)MediaTypeVideo);
+ XCTAssertEqual(options.allowsEditing, YES);
+ XCTAssertEqual(options.correctOrientation, YES);
+ XCTAssertEqual(options.saveToPhotoAlbum, YES);
+ XCTAssertEqualObjects(options.popoverOptions, popoverOptions);
+ XCTAssertEqual(options.cameraDirection, (int)UIImagePickerControllerCameraDeviceFront);
+ XCTAssertEqual(options.popoverSupported, NO);
+ XCTAssertEqual(options.usesGeolocation, NO);
+}
+
+- (void) testCameraPickerCreate
+{
+ NSDictionary* popoverOptions;
+ NSArray* args;
+ CDVPictureOptions* pictureOptions;
+ CDVCameraPicker* picker;
+
+ // Souce is Camera, and image type
+
+ popoverOptions = @{ @"x" : @1, @"y" : @2, @"width" : @3, @"height" : @4 };
+ args = @[
+ @(49),
+ @(DestinationTypeDataUrl),
+ @(UIImagePickerControllerSourceTypeCamera),
+ @(120),
+ @(240),
+ @(EncodingTypePNG),
+ @(MediaTypeAll),
+ @YES,
+ @YES,
+ @YES,
+ popoverOptions,
+ @(UIImagePickerControllerCameraDeviceFront),
+ ];
+ pictureOptions = [CDVPictureOptions createFromTakePictureArguments:args];
+
+ if ([UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType]) {
+ picker = [CDVCameraPicker createFromPictureOptions:pictureOptions];
+
+ XCTAssertEqualObjects(picker.pictureOptions, pictureOptions);
+
+ XCTAssertEqual(picker.sourceType, pictureOptions.sourceType);
+ XCTAssertEqual(picker.allowsEditing, pictureOptions.allowsEditing);
+ XCTAssertEqualObjects(picker.mediaTypes, @[(NSString*)kUTTypeImage]);
+ XCTAssertEqual(picker.cameraDevice, pictureOptions.cameraDirection);
+ }
+
+ // Souce is not Camera, and all media types
+
+ args = @[
+ @(49),
+ @(DestinationTypeDataUrl),
+ @(UIImagePickerControllerSourceTypePhotoLibrary),
+ @(120),
+ @(240),
+ @(EncodingTypePNG),
+ @(MediaTypeAll),
+ @YES,
+ @YES,
+ @YES,
+ popoverOptions,
+ @(UIImagePickerControllerCameraDeviceFront),
+ ];
+ pictureOptions = [CDVPictureOptions createFromTakePictureArguments:args];
+
+ if ([UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType]) {
+ picker = [CDVCameraPicker createFromPictureOptions:pictureOptions];
+
+ XCTAssertEqualObjects(picker.pictureOptions, pictureOptions);
+
+ XCTAssertEqual(picker.sourceType, pictureOptions.sourceType);
+ XCTAssertEqual(picker.allowsEditing, pictureOptions.allowsEditing);
+ XCTAssertEqualObjects(picker.mediaTypes, [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType]);
+ }
+
+ // Souce is not Camera, and either Image or Movie media type
+
+ args = @[
+ @(49),
+ @(DestinationTypeDataUrl),
+ @(UIImagePickerControllerSourceTypePhotoLibrary),
+ @(120),
+ @(240),
+ @(EncodingTypePNG),
+ @(MediaTypeVideo),
+ @YES,
+ @YES,
+ @YES,
+ popoverOptions,
+ @(UIImagePickerControllerCameraDeviceFront),
+ ];
+ pictureOptions = [CDVPictureOptions createFromTakePictureArguments:args];
+
+ if ([UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType]) {
+ picker = [CDVCameraPicker createFromPictureOptions:pictureOptions];
+
+ XCTAssertEqualObjects(picker.pictureOptions, pictureOptions);
+
+ XCTAssertEqual(picker.sourceType, pictureOptions.sourceType);
+ XCTAssertEqual(picker.allowsEditing, pictureOptions.allowsEditing);
+ XCTAssertEqualObjects(picker.mediaTypes, @[(NSString*)kUTTypeMovie]);
+ }
+}
+
+- (UIImage*) createImage:(CGRect)rect orientation:(UIImageOrientation)imageOrientation {
+ UIGraphicsBeginImageContext(rect.size);
+ CGContextRef context = UIGraphicsGetCurrentContext();
+
+ CGContextSetFillColorWithColor(context, [[UIColor greenColor] CGColor]);
+ CGContextFillRect(context, rect);
+
+ CGImageRef result = CGBitmapContextCreateImage(UIGraphicsGetCurrentContext());
+ UIImage* image = [UIImage imageWithCGImage:result scale:1.0f orientation:imageOrientation];
+
+ UIGraphicsEndImageContext();
+
+ return image;
+}
+
+- (void) testImageScaleCropForSize {
+
+ UIImage *sourceImagePortrait, *sourceImageLandscape, *targetImage;
+ CGSize targetSize = CGSizeZero;
+
+ sourceImagePortrait = [self createImage:CGRectMake(0, 0, 2448, 3264) orientation:UIImageOrientationUp];
+ sourceImageLandscape = [self createImage:CGRectMake(0, 0, 3264, 2448) orientation:UIImageOrientationUp];
+
+ // test 640x480
+
+ targetSize = CGSizeMake(640, 480);
+
+ targetImage = [sourceImagePortrait imageByScalingAndCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ targetImage = [sourceImageLandscape imageByScalingAndCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+
+ // test 800x600
+
+ targetSize = CGSizeMake(800, 600);
+
+ targetImage = [sourceImagePortrait imageByScalingAndCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ targetImage = [sourceImageLandscape imageByScalingAndCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ // test 1024x768
+
+ targetSize = CGSizeMake(1024, 768);
+
+ targetImage = [sourceImagePortrait imageByScalingAndCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ targetImage = [sourceImageLandscape imageByScalingAndCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+}
+
+- (void) testImageScaleNoCropForSize {
+ UIImage *sourceImagePortrait, *sourceImageLandscape, *targetImage;
+ CGSize targetSize = CGSizeZero;
+
+ sourceImagePortrait = [self createImage:CGRectMake(0, 0, 2448, 3264) orientation:UIImageOrientationUp];
+ sourceImageLandscape = [self createImage:CGRectMake(0, 0, 3264, 2448) orientation:UIImageOrientationUp];
+
+ // test 640x480
+
+ targetSize = CGSizeMake(640, 480);
+
+ targetImage = [sourceImagePortrait imageByScalingNotCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ targetImage = [sourceImageLandscape imageByScalingNotCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+
+ // test 800x600
+
+ targetSize = CGSizeMake(800, 600);
+
+ targetImage = [sourceImagePortrait imageByScalingNotCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ targetImage = [sourceImageLandscape imageByScalingNotCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ // test 1024x768
+
+ targetSize = CGSizeMake(1024, 768);
+
+ targetImage = [sourceImagePortrait imageByScalingNotCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ targetImage = [sourceImageLandscape imageByScalingNotCroppingForSize:targetSize];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+}
+
+- (void) testImageCorrectedForOrientation {
+ UIImage *sourceImagePortrait, *sourceImageLandscape, *targetImage;
+ CGSize targetSize = CGSizeZero;
+
+ sourceImagePortrait = [self createImage:CGRectMake(0, 0, 2448, 3264) orientation:UIImageOrientationDown];
+ sourceImageLandscape = [self createImage:CGRectMake(0, 0, 3264, 2448) orientation:UIImageOrientationDown];
+
+ // PORTRAIT - image size should be unchanged
+
+ targetSize = CGSizeMake(2448, 3264);
+
+ targetImage = [sourceImagePortrait imageCorrectedForCaptureOrientation:UIImageOrientationUp];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+ XCTAssertEqual(targetImage.imageOrientation, UIImageOrientationUp);
+
+ targetImage = [sourceImagePortrait imageCorrectedForCaptureOrientation:UIImageOrientationDown];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+ XCTAssertEqual(targetImage.imageOrientation, UIImageOrientationUp);
+
+ targetImage = [sourceImagePortrait imageCorrectedForCaptureOrientation:UIImageOrientationRight];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+ XCTAssertEqual(targetImage.imageOrientation, UIImageOrientationUp);
+
+ targetImage = [sourceImagePortrait imageCorrectedForCaptureOrientation:UIImageOrientationLeft];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+ XCTAssertEqual(targetImage.imageOrientation, UIImageOrientationUp);
+
+ // LANDSCAPE - image size should be unchanged
+
+ targetSize = CGSizeMake(3264, 2448);
+
+ targetImage = [sourceImageLandscape imageCorrectedForCaptureOrientation:UIImageOrientationUp];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ targetImage = [sourceImageLandscape imageCorrectedForCaptureOrientation:UIImageOrientationDown];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ targetImage = [sourceImageLandscape imageCorrectedForCaptureOrientation:UIImageOrientationRight];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+
+ targetImage = [sourceImageLandscape imageCorrectedForCaptureOrientation:UIImageOrientationLeft];
+ XCTAssertEqual(targetImage.size.width, targetSize.width);
+ XCTAssertEqual(targetImage.size.height, targetSize.height);
+}
+
+
+- (void) testRetrieveImage
+{
+ CDVPictureOptions* pictureOptions = [[CDVPictureOptions alloc] init];
+ NSDictionary *infoDict1, *infoDict2;
+ UIImage* resultImage;
+
+ UIImage* originalImage = [self createImage:CGRectMake(0, 0, 1024, 768) orientation:UIImageOrientationDown];
+ UIImage* originalCorrectedForOrientation = [originalImage imageCorrectedForCaptureOrientation];
+
+ UIImage* editedImage = [self createImage:CGRectMake(0, 0, 800, 600) orientation:UIImageOrientationDown];
+ UIImage* scaledImageWithCrop = [originalImage imageByScalingAndCroppingForSize:CGSizeMake(640, 480)];
+ UIImage* scaledImageNoCrop = [originalImage imageByScalingNotCroppingForSize:CGSizeMake(640, 480)];
+
+ infoDict1 = @{
+ UIImagePickerControllerOriginalImage : originalImage
+ };
+
+ infoDict2 = @{
+ UIImagePickerControllerOriginalImage : originalImage,
+ UIImagePickerControllerEditedImage : editedImage
+ };
+
+ // Original with no options
+
+ pictureOptions.allowsEditing = YES;
+ pictureOptions.targetSize = CGSizeZero;
+ pictureOptions.cropToSize = NO;
+ pictureOptions.correctOrientation = NO;
+
+ resultImage = [self.plugin retrieveImage:infoDict1 options:pictureOptions];
+ XCTAssertEqualObjects(resultImage, originalImage);
+
+ // Original with no options
+
+ pictureOptions.allowsEditing = YES;
+ pictureOptions.targetSize = CGSizeZero;
+ pictureOptions.cropToSize = NO;
+ pictureOptions.correctOrientation = NO;
+
+ resultImage = [self.plugin retrieveImage:infoDict2 options:pictureOptions];
+ XCTAssertEqualObjects(resultImage, editedImage);
+
+ // Original with corrected orientation
+
+ pictureOptions.allowsEditing = YES;
+ pictureOptions.targetSize = CGSizeZero;
+ pictureOptions.cropToSize = NO;
+ pictureOptions.correctOrientation = YES;
+
+ resultImage = [self.plugin retrieveImage:infoDict1 options:pictureOptions];
+ XCTAssertNotEqual(resultImage.imageOrientation, originalImage.imageOrientation);
+ XCTAssertEqual(resultImage.imageOrientation, originalCorrectedForOrientation.imageOrientation);
+ XCTAssertEqual(resultImage.size.width, originalCorrectedForOrientation.size.width);
+ XCTAssertEqual(resultImage.size.height, originalCorrectedForOrientation.size.height);
+
+ // Original with targetSize, no crop
+
+ pictureOptions.allowsEditing = YES;
+ pictureOptions.targetSize = CGSizeMake(640, 480);
+ pictureOptions.cropToSize = NO;
+ pictureOptions.correctOrientation = NO;
+
+ resultImage = [self.plugin retrieveImage:infoDict1 options:pictureOptions];
+ XCTAssertEqual(resultImage.size.width, scaledImageNoCrop.size.width);
+ XCTAssertEqual(resultImage.size.height, scaledImageNoCrop.size.height);
+
+ // Original with targetSize, plus crop
+
+ pictureOptions.allowsEditing = YES;
+ pictureOptions.targetSize = CGSizeMake(640, 480);
+ pictureOptions.cropToSize = YES;
+ pictureOptions.correctOrientation = NO;
+
+ resultImage = [self.plugin retrieveImage:infoDict1 options:pictureOptions];
+ XCTAssertEqual(resultImage.size.width, scaledImageWithCrop.size.width);
+ XCTAssertEqual(resultImage.size.height, scaledImageWithCrop.size.height);
+}
+
+- (void) testProcessImage
+{
+ CDVPictureOptions* pictureOptions = [[CDVPictureOptions alloc] init];
+ NSData* resultData;
+
+ UIImage* originalImage = [self createImage:CGRectMake(0, 0, 1024, 768) orientation:UIImageOrientationDown];
+ NSData* originalImageDataPNG = UIImagePNGRepresentation(originalImage);
+ NSData* originalImageDataJPEG = UIImageJPEGRepresentation(originalImage, 1.0);
+
+ // Original, PNG
+
+ pictureOptions.allowsEditing = YES;
+ pictureOptions.targetSize = CGSizeZero;
+ pictureOptions.cropToSize = NO;
+ pictureOptions.correctOrientation = NO;
+ pictureOptions.encodingType = EncodingTypePNG;
+
+ resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions];
+ XCTAssertEqualObjects([resultData base64EncodedString], [originalImageDataPNG base64EncodedString]);
+
+ // Original, JPEG, full quality
+
+ pictureOptions.allowsEditing = NO;
+ pictureOptions.targetSize = CGSizeZero;
+ pictureOptions.cropToSize = NO;
+ pictureOptions.correctOrientation = NO;
+ pictureOptions.encodingType = EncodingTypeJPEG;
+
+ resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions];
+ XCTAssertEqualObjects([resultData base64EncodedString], [originalImageDataJPEG base64EncodedString]);
+
+ // Original, JPEG, with quality value
+
+ pictureOptions.allowsEditing = YES;
+ pictureOptions.targetSize = CGSizeZero;
+ pictureOptions.cropToSize = NO;
+ pictureOptions.correctOrientation = NO;
+ pictureOptions.encodingType = EncodingTypeJPEG;
+ pictureOptions.quality = @(57);
+
+ NSData* originalImageDataJPEGWithQuality = UIImageJPEGRepresentation(originalImage, [pictureOptions.quality floatValue]/ 100.f);
+ resultData = [self.plugin processImage:originalImage info:@{} options:pictureOptions];
+ XCTAssertEqualObjects([resultData base64EncodedString], [originalImageDataJPEGWithQuality base64EncodedString]);
+
+ // TODO: usesGeolocation is not tested
+}
+
+@end
diff --git a/tests/ios/CDVCameraTest/CDVCameraLibTests/Info.plist b/tests/ios/CDVCameraTest/CDVCameraLibTests/Info.plist
new file mode 100644
index 0000000..a949946
--- /dev/null
+++ b/tests/ios/CDVCameraTest/CDVCameraLibTests/Info.plist
@@ -0,0 +1,24 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ org.apache.cordova.$(PRODUCT_NAME:rfc1034identifier)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ BNDL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1
+
+
diff --git a/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.pbxproj b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..3e5a4c0
--- /dev/null
+++ b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.pbxproj
@@ -0,0 +1,561 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 30486FEB1A40DC350065C233 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FEA1A40DC350065C233 /* UIKit.framework */; };
+ 30486FED1A40DC3B0065C233 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FEC1A40DC3A0065C233 /* Foundation.framework */; };
+ 30486FF91A40DCC70065C233 /* CDVCamera.m in Sources */ = {isa = PBXBuildFile; fileRef = 30486FF31A40DCC70065C233 /* CDVCamera.m */; };
+ 30486FFA1A40DCC70065C233 /* CDVJpegHeaderWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 30486FF61A40DCC70065C233 /* CDVJpegHeaderWriter.m */; };
+ 30486FFB1A40DCC70065C233 /* UIImage+CropScaleOrientation.m in Sources */ = {isa = PBXBuildFile; fileRef = 30486FF81A40DCC70065C233 /* UIImage+CropScaleOrientation.m */; };
+ 304870011A40DD620065C233 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FFE1A40DD180065C233 /* CoreGraphics.framework */; };
+ 304870021A40DD860065C233 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FFE1A40DD180065C233 /* CoreGraphics.framework */; };
+ 304870031A40DD8C0065C233 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30486FEA1A40DC350065C233 /* UIKit.framework */; };
+ 304870051A40DD9A0065C233 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 304870041A40DD9A0065C233 /* MobileCoreServices.framework */; };
+ 304870071A40DDAC0065C233 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 304870061A40DDAC0065C233 /* AssetsLibrary.framework */; };
+ 304870091A40DDB90065C233 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 304870081A40DDB90065C233 /* CoreLocation.framework */; };
+ 3048700B1A40DDF30065C233 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3048700A1A40DDF30065C233 /* ImageIO.framework */; };
+ 308F59B11A4228730031A4D4 /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E9F519019DA0F8300DA31AC /* libCordova.a */; };
+ 7E9F51B119DA114400DA31AC /* CameraTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9F51B019DA114400DA31AC /* CameraTest.m */; };
+ 7E9F51B919DA1B1600DA31AC /* libCDVCameraLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E9F519519DA102000DA31AC /* libCDVCameraLib.a */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ 30486FFC1A40DCE80065C233 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */;
+ proxyType = 1;
+ remoteGlobalIDString = D2AAC07D0554694100DB518D;
+ remoteInfo = CordovaLib;
+ };
+ 7E9F518F19DA0F8300DA31AC /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */;
+ proxyType = 2;
+ remoteGlobalIDString = 68A32D7114102E1C006B237C;
+ remoteInfo = CordovaLib;
+ };
+ 7E9F51AC19DA10DE00DA31AC /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 7E9F517219DA09CE00DA31AC /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 7E9F519419DA102000DA31AC;
+ remoteInfo = CDVCameraLib;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 7E9F519319DA102000DA31AC /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "include/$(PRODUCT_NAME)";
+ dstSubfolderSpec = 16;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 30486FEA1A40DC350065C233 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
+ 30486FEC1A40DC3A0065C233 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
+ 30486FF21A40DCC70065C233 /* CDVCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVCamera.h; sourceTree = ""; };
+ 30486FF31A40DCC70065C233 /* CDVCamera.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVCamera.m; sourceTree = ""; };
+ 30486FF41A40DCC70065C233 /* CDVExif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVExif.h; sourceTree = ""; };
+ 30486FF51A40DCC70065C233 /* CDVJpegHeaderWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVJpegHeaderWriter.h; sourceTree = ""; };
+ 30486FF61A40DCC70065C233 /* CDVJpegHeaderWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVJpegHeaderWriter.m; sourceTree = ""; };
+ 30486FF71A40DCC70065C233 /* UIImage+CropScaleOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+CropScaleOrientation.h"; sourceTree = ""; };
+ 30486FF81A40DCC70065C233 /* UIImage+CropScaleOrientation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+CropScaleOrientation.m"; sourceTree = ""; };
+ 30486FFE1A40DD180065C233 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; };
+ 304870041A40DD9A0065C233 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; };
+ 304870061A40DDAC0065C233 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/AssetsLibrary.framework; sourceTree = DEVELOPER_DIR; };
+ 304870081A40DDB90065C233 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/CoreLocation.framework; sourceTree = DEVELOPER_DIR; };
+ 3048700A1A40DDF30065C233 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/ImageIO.framework; sourceTree = DEVELOPER_DIR; };
+ 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = "../node_modules/cordova-ios/CordovaLib/CordovaLib.xcodeproj"; sourceTree = ""; };
+ 7E9F519519DA102000DA31AC /* libCDVCameraLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCDVCameraLib.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7E9F519F19DA102000DA31AC /* CDVCameraLibTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CDVCameraLibTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7E9F51A219DA102000DA31AC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ 7E9F51B019DA114400DA31AC /* CameraTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CameraTest.m; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 7E9F519219DA102000DA31AC /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 308F59B11A4228730031A4D4 /* libCordova.a in Frameworks */,
+ 304870011A40DD620065C233 /* CoreGraphics.framework in Frameworks */,
+ 30486FED1A40DC3B0065C233 /* Foundation.framework in Frameworks */,
+ 30486FEB1A40DC350065C233 /* UIKit.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 7E9F519C19DA102000DA31AC /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 3048700B1A40DDF30065C233 /* ImageIO.framework in Frameworks */,
+ 304870091A40DDB90065C233 /* CoreLocation.framework in Frameworks */,
+ 304870071A40DDAC0065C233 /* AssetsLibrary.framework in Frameworks */,
+ 304870051A40DD9A0065C233 /* MobileCoreServices.framework in Frameworks */,
+ 304870031A40DD8C0065C233 /* UIKit.framework in Frameworks */,
+ 304870021A40DD860065C233 /* CoreGraphics.framework in Frameworks */,
+ 7E9F51B919DA1B1600DA31AC /* libCDVCameraLib.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 30486FF11A40DCC70065C233 /* CDVCameraLib */ = {
+ isa = PBXGroup;
+ children = (
+ 30486FF21A40DCC70065C233 /* CDVCamera.h */,
+ 30486FF31A40DCC70065C233 /* CDVCamera.m */,
+ 30486FF41A40DCC70065C233 /* CDVExif.h */,
+ 30486FF51A40DCC70065C233 /* CDVJpegHeaderWriter.h */,
+ 30486FF61A40DCC70065C233 /* CDVJpegHeaderWriter.m */,
+ 30486FF71A40DCC70065C233 /* UIImage+CropScaleOrientation.h */,
+ 30486FF81A40DCC70065C233 /* UIImage+CropScaleOrientation.m */,
+ );
+ name = CDVCameraLib;
+ path = ../../../src/ios;
+ sourceTree = "";
+ };
+ 308F59B01A4227A60031A4D4 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 3048700A1A40DDF30065C233 /* ImageIO.framework */,
+ 304870081A40DDB90065C233 /* CoreLocation.framework */,
+ 304870061A40DDAC0065C233 /* AssetsLibrary.framework */,
+ 304870041A40DD9A0065C233 /* MobileCoreServices.framework */,
+ 30486FFE1A40DD180065C233 /* CoreGraphics.framework */,
+ 30486FEC1A40DC3A0065C233 /* Foundation.framework */,
+ 30486FEA1A40DC350065C233 /* UIKit.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
+ 7E9F517119DA09CE00DA31AC = {
+ isa = PBXGroup;
+ children = (
+ 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */,
+ 308F59B01A4227A60031A4D4 /* Frameworks */,
+ 30486FF11A40DCC70065C233 /* CDVCameraLib */,
+ 7E9F51A019DA102000DA31AC /* CDVCameraLibTests */,
+ 7E9F517D19DA0A0A00DA31AC /* Products */,
+ );
+ sourceTree = "";
+ };
+ 7E9F517D19DA0A0A00DA31AC /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 7E9F519519DA102000DA31AC /* libCDVCameraLib.a */,
+ 7E9F519F19DA102000DA31AC /* CDVCameraLibTests.xctest */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 7E9F518C19DA0F8300DA31AC /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 7E9F519019DA0F8300DA31AC /* libCordova.a */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 7E9F51A019DA102000DA31AC /* CDVCameraLibTests */ = {
+ isa = PBXGroup;
+ children = (
+ 7E9F51A119DA102000DA31AC /* Supporting Files */,
+ 7E9F51B019DA114400DA31AC /* CameraTest.m */,
+ );
+ path = CDVCameraLibTests;
+ sourceTree = "";
+ };
+ 7E9F51A119DA102000DA31AC /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 7E9F51A219DA102000DA31AC /* Info.plist */,
+ );
+ name = "Supporting Files";
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 7E9F519419DA102000DA31AC /* CDVCameraLib */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 7E9F51A319DA102000DA31AC /* Build configuration list for PBXNativeTarget "CDVCameraLib" */;
+ buildPhases = (
+ 7E9F519119DA102000DA31AC /* Sources */,
+ 7E9F519219DA102000DA31AC /* Frameworks */,
+ 7E9F519319DA102000DA31AC /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 30486FFD1A40DCE80065C233 /* PBXTargetDependency */,
+ );
+ name = CDVCameraLib;
+ productName = CDVCameraLib;
+ productReference = 7E9F519519DA102000DA31AC /* libCDVCameraLib.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+ 7E9F519E19DA102000DA31AC /* CDVCameraLibTests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 7E9F51A619DA102000DA31AC /* Build configuration list for PBXNativeTarget "CDVCameraLibTests" */;
+ buildPhases = (
+ 7E9F519B19DA102000DA31AC /* Sources */,
+ 7E9F519C19DA102000DA31AC /* Frameworks */,
+ 7E9F519D19DA102000DA31AC /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 7E9F51AD19DA10DE00DA31AC /* PBXTargetDependency */,
+ );
+ name = CDVCameraLibTests;
+ productName = CDVCameraLibTests;
+ productReference = 7E9F519F19DA102000DA31AC /* CDVCameraLibTests.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 7E9F517219DA09CE00DA31AC /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0610;
+ TargetAttributes = {
+ 7E9F519419DA102000DA31AC = {
+ CreatedOnToolsVersion = 6.0;
+ };
+ 7E9F519E19DA102000DA31AC = {
+ CreatedOnToolsVersion = 6.0;
+ };
+ };
+ };
+ buildConfigurationList = 7E9F517519DA09CE00DA31AC /* Build configuration list for PBXProject "CDVCameraTest" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 7E9F517119DA09CE00DA31AC;
+ productRefGroup = 7E9F517D19DA0A0A00DA31AC /* Products */;
+ projectDirPath = "";
+ projectReferences = (
+ {
+ ProductGroup = 7E9F518C19DA0F8300DA31AC /* Products */;
+ ProjectRef = 7E9F518B19DA0F8300DA31AC /* CordovaLib.xcodeproj */;
+ },
+ );
+ projectRoot = "";
+ targets = (
+ 7E9F519419DA102000DA31AC /* CDVCameraLib */,
+ 7E9F519E19DA102000DA31AC /* CDVCameraLibTests */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXReferenceProxy section */
+ 7E9F519019DA0F8300DA31AC /* libCordova.a */ = {
+ isa = PBXReferenceProxy;
+ fileType = archive.ar;
+ path = libCordova.a;
+ remoteRef = 7E9F518F19DA0F8300DA31AC /* PBXContainerItemProxy */;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+/* End PBXReferenceProxy section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 7E9F519D19DA102000DA31AC /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 7E9F519119DA102000DA31AC /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 30486FF91A40DCC70065C233 /* CDVCamera.m in Sources */,
+ 30486FFB1A40DCC70065C233 /* UIImage+CropScaleOrientation.m in Sources */,
+ 30486FFA1A40DCC70065C233 /* CDVJpegHeaderWriter.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 7E9F519B19DA102000DA31AC /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 7E9F51B119DA114400DA31AC /* CameraTest.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 30486FFD1A40DCE80065C233 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = CordovaLib;
+ targetProxy = 30486FFC1A40DCE80065C233 /* PBXContainerItemProxy */;
+ };
+ 7E9F51AD19DA10DE00DA31AC /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 7E9F519419DA102000DA31AC /* CDVCameraLib */;
+ targetProxy = 7E9F51AC19DA10DE00DA31AC /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+ 7E9F517619DA09CE00DA31AC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ONLY_ACTIVE_ARCH = YES;
+ };
+ name = Debug;
+ };
+ 7E9F517719DA09CE00DA31AC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ };
+ name = Release;
+ };
+ 7E9F51A419DA102000DA31AC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(TARGET_BUILD_DIR)/usr/local/lib/include\"",
+ "\"$(OBJROOT)/UninstalledProducts/include\"",
+ "\"$(BUILT_PRODUCTS_DIR)\"",
+ );
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ 7E9F51A519DA102000DA31AC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = YES;
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(TARGET_BUILD_DIR)/usr/local/lib/include\"",
+ "\n\"$(OBJROOT)/UninstalledProducts/include\"\n\"$(BUILT_PRODUCTS_DIR)\"",
+ );
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 7E9F51A719DA102000DA31AC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(SDKROOT)/Developer/Library/Frameworks",
+ "$(inherited)",
+ );
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ INFOPLIST_FILE = CDVCameraLibTests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ OTHER_LDFLAGS = (
+ "$(inherited)",
+ "-framework",
+ XCTest,
+ "-all_load",
+ "-ObjC",
+ );
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ 7E9F51A819DA102000DA31AC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = YES;
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(SDKROOT)/Developer/Library/Frameworks",
+ "$(inherited)",
+ );
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ INFOPLIST_FILE = CDVCameraLibTests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ MTL_ENABLE_DEBUG_INFO = NO;
+ OTHER_LDFLAGS = (
+ "$(inherited)",
+ "-framework",
+ XCTest,
+ "-all_load",
+ "-ObjC",
+ );
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 7E9F517519DA09CE00DA31AC /* Build configuration list for PBXProject "CDVCameraTest" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 7E9F517619DA09CE00DA31AC /* Debug */,
+ 7E9F517719DA09CE00DA31AC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 7E9F51A319DA102000DA31AC /* Build configuration list for PBXNativeTarget "CDVCameraLib" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 7E9F51A419DA102000DA31AC /* Debug */,
+ 7E9F51A519DA102000DA31AC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 7E9F51A619DA102000DA31AC /* Build configuration list for PBXNativeTarget "CDVCameraLibTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 7E9F51A719DA102000DA31AC /* Debug */,
+ 7E9F51A819DA102000DA31AC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 7E9F517219DA09CE00DA31AC /* Project object */;
+}
diff --git a/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..98498f8
--- /dev/null
+++ b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/xcshareddata/CDVCameraTest.xccheckout b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/xcshareddata/CDVCameraTest.xccheckout
new file mode 100644
index 0000000..2a654cb
--- /dev/null
+++ b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/project.xcworkspace/xcshareddata/CDVCameraTest.xccheckout
@@ -0,0 +1,41 @@
+
+
+
+
+ IDESourceControlProjectFavoriteDictionaryKey
+
+ IDESourceControlProjectIdentifier
+ 6BE9AD73-1B9F-4362-98D7-DC631BEC6185
+ IDESourceControlProjectName
+ CDVCameraTest
+ IDESourceControlProjectOriginsDictionary
+
+ BEF5A5D0FF64801E558286389440357A9233D7DB
+ https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
+
+ IDESourceControlProjectPath
+ tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj
+ IDESourceControlProjectRelativeInstallPathDictionary
+
+ BEF5A5D0FF64801E558286389440357A9233D7DB
+ ../../../../..
+
+ IDESourceControlProjectURL
+ https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
+ IDESourceControlProjectVersion
+ 111
+ IDESourceControlProjectWCCIdentifier
+ BEF5A5D0FF64801E558286389440357A9233D7DB
+ IDESourceControlProjectWCConfigurations
+
+
+ IDESourceControlRepositoryExtensionIdentifierKey
+ public.vcs.git
+ IDESourceControlWCCIdentifierKey
+ BEF5A5D0FF64801E558286389440357A9233D7DB
+ IDESourceControlWCCName
+ cordova-plugin-camera
+
+
+
+
diff --git a/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLib.xcscheme b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLib.xcscheme
new file mode 100644
index 0000000..f0a8304
--- /dev/null
+++ b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLib.xcscheme
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLibTests.xcscheme b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLibTests.xcscheme
new file mode 100644
index 0000000..b5d2603
--- /dev/null
+++ b/tests/ios/CDVCameraTest/CDVCameraTest.xcodeproj/xcshareddata/xcschemes/CDVCameraLibTests.xcscheme
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/ios/README.md b/tests/ios/README.md
new file mode 100644
index 0000000..631ae2c
--- /dev/null
+++ b/tests/ios/README.md
@@ -0,0 +1,21 @@
+# iOS Tests for CDVCamera
+
+You need to install `node.js` to pull in `cordova-ios`.
+
+First install cordova-ios:
+
+ npm install
+
+... in the current folder.
+
+
+# Testing from Xcode
+
+1. Launch the `CDVCameraTest.xcworkspace` file.
+2. Choose "CDVCameraLibTests" from the scheme drop-down menu
+3. Click and hold on the `Play` button, and choose the `Wrench` icon to run the tests
+
+
+# Testing from the command line
+
+ npm test
diff --git a/tests/ios/package.json b/tests/ios/package.json
new file mode 100644
index 0000000..84bd9ec
--- /dev/null
+++ b/tests/ios/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "cordova-plugin-camera-test-ios",
+ "version": "1.0.0",
+ "description": "iOS Unit Tests for Camera Plugin",
+ "author": "Apache Software Foundation",
+ "license": "Apache Version 2.0",
+ "dependencies": {
+ "cordova-ios": "^3.7.0"
+ },
+ "scripts": {
+ "test": "xcodebuild -scheme CordovaLib && xcodebuild test -scheme CDVCameraLibTests -destination 'platform=iOS Simulator,name=iPhone 5'"
+ }
+}
\ No newline at end of file