Skip to content

Commit

Permalink
Merge pull request #213 from ruslanskorb/develop
Browse files Browse the repository at this point in the history
Version 2.2.3
  • Loading branch information
ruslanskorb authored Jul 25, 2019
2 parents 4f69983 + 3494d29 commit 63e36bd
Show file tree
Hide file tree
Showing 30 changed files with 133 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.2.2</string>
<string>2.2.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
114 changes: 81 additions & 33 deletions Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ - (void)onChooseButtonTouch:(UIBarButtonItem *)sender;
- (void)layoutImageScrollView;
- (void)reset:(BOOL)animated;
- (void)resetContentOffset;
- (void)resetFrame;
- (void)resetRotation;
- (void)resetZoomScale;

Expand Down Expand Up @@ -219,17 +218,24 @@ - (void)resetZoomScale;
});

describe(@"crop image", ^{
__block UIImageView *croppedImageImageView = nil;

dispatch_block_t sharedIt = ^{
UIImage *croppedImage = [imageCropViewController croppedImage:imageCropViewController.originalImage cropMode:imageCropViewController.cropMode cropRect:imageCropViewController.cropRect imageRect:imageCropViewController.imageRect rotationAngle:imageCropViewController.rotationAngle zoomScale:imageCropViewController.zoomScale maskPath:imageCropViewController.maskPath applyMaskToCroppedImage:imageCropViewController.applyMaskToCroppedImage];

expect(croppedImage).notTo.beNil();
expect(croppedImage.imageOrientation).to.equal(UIImageOrientationUp);
expect(croppedImage.scale).to.equal(imageCropViewController.originalImage.scale);

croppedImageImageView.image = croppedImage;
expect(croppedImageImageView).haveValidSnapshot();
};

describe(@"crop mode is `RSKImageCropModeCircle`", ^{
before(^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];
croppedImageImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 130.0, 130.0)];
croppedImageImageView.contentMode = UIViewContentModeScaleAspectFit;

sharedLoadView();
});
Expand All @@ -244,6 +250,19 @@ - (void)resetZoomScale;
sharedIt();
});

it(@"correctly crop the image when content offset is not equal to 0", ^{
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when rotation angle and content offset are not equal to 0", ^{
imageCropViewController.rotationAngle = M_PI_4;
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when `applyMaskToCroppedImage` is `YES`", ^{
imageCropViewController.applyMaskToCroppedImage = YES;

Expand Down Expand Up @@ -272,6 +291,19 @@ - (void)resetZoomScale;
sharedIt();
});

it(@"correctly crop the image when content offset are not equal to 0", ^{
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when rotation angle and content offset are not equal to 0", ^{
imageCropViewController.rotationAngle = M_PI_4;
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when `applyMaskToCroppedImage` is `YES`", ^{
imageCropViewController.applyMaskToCroppedImage = YES;

Expand All @@ -284,8 +316,10 @@ - (void)resetZoomScale;
});

describe(@"crop mode is `RSKImageCropModeCustom`", ^{
__block id <RSKImageCropViewControllerDataSource> dataSourceObject = nil;

before(^{
RSKImageCropViewControllerDataSourceObject1 *dataSourceObject = [[RSKImageCropViewControllerDataSourceObject1 alloc] init];
dataSourceObject = [[RSKImageCropViewControllerDataSourceObject1 alloc] init];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCustom];
imageCropViewController.dataSource = dataSourceObject;
Expand All @@ -303,76 +337,87 @@ - (void)resetZoomScale;
sharedIt();
});

it(@"correctly crop the image when content offset are not equal to 0", ^{
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when rotation angle and content offset are not equal to 0", ^{
imageCropViewController.rotationAngle = M_PI_4;
imageCropViewController.imageScrollView.contentOffset = CGPointMake(84.0, 122.0);

sharedIt();
});

it(@"correctly crop the image when `applyMaskToCroppedImage` is `YES`", ^{
imageCropViewController.applyMaskToCroppedImage = YES;

sharedIt();
});

after(^{
dataSourceObject = nil;
imageCropViewController = nil;
});
});

describe(@"crop image with any image orientation", ^{
before(^{
imageCropViewController = [[RSKImageCropViewController alloc] init];
});

it(@"UIImageOrientationDown", ^{
UIImage *downImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationDown];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:downImage];
imageCropViewController.originalImage = downImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationLeft", ^{
UIImage *leftImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationLeft];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:leftImage];
imageCropViewController.originalImage = leftImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationRight", ^{
UIImage *rightImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationRight];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:rightImage];
imageCropViewController.originalImage = rightImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationUpMirrored", ^{
UIImage *upMirroredImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationUpMirrored];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:upMirroredImage];
imageCropViewController.originalImage = upMirroredImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationDownMirrored", ^{
UIImage *downMirroredImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationDownMirrored];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:downMirroredImage];
imageCropViewController.originalImage = downMirroredImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationLeftMirrored", ^{
UIImage *leftMirroredImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationLeftMirrored];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:leftMirroredImage];
imageCropViewController.originalImage = leftMirroredImage;

sharedLoadView();
sharedIt();
});

it(@"UIImageOrientationRightMirrored", ^{
UIImage *rightMirroredImage = [UIImage imageWithCGImage:originalImage.CGImage scale:originalImage.scale orientation:UIImageOrientationRightMirrored];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:rightMirroredImage];
imageCropViewController.originalImage = rightMirroredImage;

sharedLoadView();
sharedIt();
Expand Down Expand Up @@ -523,30 +568,28 @@ - (void)resetZoomScale;
});

describe(@"crop view", ^{
dispatch_block_t sharedIt = ^{
sharedLoadView();

expect(imageCropViewController.view).to.haveValidSnapshot();
};

describe(@"portrait", ^{
dispatch_block_t sharedPortraitIt = ^{
imageCropViewController.view.frame = CGRectMake(0, 0, 320, 568);

sharedIt();
sharedLoadView();
};

describe(@"crop mode", ^{
it(@"looks right when crop mode is `RSKImageCropModeCircle`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];

sharedPortraitIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});

it(@"looks right when crop mode is `RSKImageCropModeSquare`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];

sharedPortraitIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});

it(@"looks right when crop mode is `RSKImageCropModeCustom`", ^{
Expand All @@ -556,6 +599,8 @@ - (void)resetZoomScale;
imageCropViewController.dataSource = dataSourceObject;

sharedPortraitIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});
});

Expand All @@ -565,6 +610,8 @@ - (void)resetZoomScale;
imageCropViewController.maskLayerStrokeColor = [UIColor whiteColor];

sharedPortraitIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});
});
});
Expand All @@ -573,20 +620,24 @@ - (void)resetZoomScale;
dispatch_block_t sharedLandscapeIt = ^{
imageCropViewController.view.frame = CGRectMake(0, 0, 568, 320);

sharedIt();
sharedLoadView();
};

describe(@"crop mode", ^{
it(@"looks right when crop mode is `RSKImageCropModeCircle`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];

sharedLandscapeIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});

it(@"looks right when crop mode is `RSKImageCropModeSquare`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];

sharedLandscapeIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});

it(@"looks right when crop mode is `RSKImageCropModeCustom`", ^{
Expand All @@ -596,6 +647,8 @@ - (void)resetZoomScale;
imageCropViewController.dataSource = dataSourceObject;

sharedLandscapeIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});
});

Expand All @@ -605,6 +658,8 @@ - (void)resetZoomScale;
imageCropViewController.maskLayerStrokeColor = [UIColor whiteColor];

sharedLandscapeIt();

expect(imageCropViewController.view).to.haveValidSnapshot();
});
});
});
Expand Down Expand Up @@ -824,14 +879,6 @@ - (void)resetZoomScale;
expect(imageCropViewController.rotationAngle).to.equal(initialRotationAngle);
});

it(@"should reset frame", ^{
CGRect initialFrame = imageCropViewController.imageScrollView.frame;
CGRect testFrame = CGRectOffset(imageCropViewController.maskRect, 100, 100);
imageCropViewController.imageScrollView.frame = testFrame;
[imageCropViewController resetFrame];
expect(imageCropViewController.imageScrollView.frame).to.equal(initialFrame);
});

it(@"should reset zoom scale", ^{
CGFloat initialZoomScale = imageCropViewController.zoomScale;
CGFloat testZoomScale = initialZoomScale + 0.1;
Expand Down Expand Up @@ -912,12 +959,13 @@ - (void)resetZoomScale;
imageCropViewController = [[RSKImageCropViewController alloc] init];
id mockImageCropViewController = [OCMockObject partialMockForObject:imageCropViewController];

[[mockImageCropViewController expect] setRotationAngle:testRotationAngle];
[[mockImageCropViewController expect] layoutImageScrollView];

[mockImageCropViewController handleRotation:mockRotationGestureRecognizer];

expect(imageCropViewController.rotationAngle).to.equal(testRotationAngle);
[mockImageCropViewController verifyWithDelay:kLayoutImageScrollViewAnimationDuration];

[mockImageCropViewController stopMocking];
});

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...mages/RSKImageScrollViewSpec/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Framework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.2.2</string>
<string>2.2.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion RSKImageCropper.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RSKImageCropper'
s.version = '2.2.2'
s.version = '2.2.3'
s.summary = 'An image cropper for iOS like in the Contacts app with support for landscape orientation.'
s.homepage = 'https://github.com/ruslanskorb/RSKImageCropper'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
12 changes: 6 additions & 6 deletions RSKImageCropper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2.2.2;
CURRENT_PROJECT_VERSION = 2.2.3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -297,7 +297,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2.2.2;
CURRENT_PROJECT_VERSION = 2.2.3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -324,8 +324,8 @@
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.2.2;
DYLIB_CURRENT_VERSION = 2.2.2;
DYLIB_COMPATIBILITY_VERSION = 2.2.3;
DYLIB_CURRENT_VERSION = 2.2.3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Framework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -342,8 +342,8 @@
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 2.2.2;
DYLIB_CURRENT_VERSION = 2.2.2;
DYLIB_COMPATIBILITY_VERSION = 2.2.3;
DYLIB_CURRENT_VERSION = 2.2.3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Framework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down
Loading

0 comments on commit 63e36bd

Please sign in to comment.