From 08c3a67daea33c3bfdcd6ea3b97704382931907c Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Tue, 25 Jun 2013 21:39:04 +0900 Subject: [PATCH 01/10] Implement UIView#captureBase64PngImage and support GLKView. --- src/UIView+ImageCapture.h | 1 + src/UIView+ImageCapture.m | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/UIView+ImageCapture.h b/src/UIView+ImageCapture.h index bbbd2681..4bea8bd9 100644 --- a/src/UIView+ImageCapture.h +++ b/src/UIView+ImageCapture.h @@ -11,5 +11,6 @@ @interface UIView (ImageCapture) - (UIImage *)captureImage; +- (NSString *)captureBase64PngImage; @end diff --git a/src/UIView+ImageCapture.m b/src/UIView+ImageCapture.m index 692a8fa8..a2d0cc72 100644 --- a/src/UIView+ImageCapture.m +++ b/src/UIView+ImageCapture.m @@ -8,10 +8,15 @@ #import "UIView+ImageCapture.h" #import +#import "DDData.h" @implementation UIView (ImageCapture) - (UIImage *)captureImage { + if ([self respondsToSelector:@selector(snapshot)]) { + return [self performSelector:@selector(snapshot)]; + } + UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; @@ -22,4 +27,13 @@ - (UIImage *)captureImage { return image; } +- (NSString *)captureBase64PngImage { + UIImage* image = [self captureImage]; + if ( image ) { + NSData *imgData = UIImagePNGRepresentation(image); + return [imgData base64Encoded]; + } + return nil; +} + @end From babde74baca73f9927c3e307abc3430a8186cc1a Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Tue, 25 Jun 2013 21:39:24 +0900 Subject: [PATCH 02/10] Implement NSView#captureBase64PngImage --- src/NSView+FrankImageCapture.h | 1 + src/NSView+FrankImageCapture.m | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/NSView+FrankImageCapture.h b/src/NSView+FrankImageCapture.h index acb3bac0..b6fcd906 100644 --- a/src/NSView+FrankImageCapture.h +++ b/src/NSView+FrankImageCapture.h @@ -12,5 +12,6 @@ + (NSImage *) captureImageOfSize:(CGSize)size fromViews:(NSArray *)views; - (NSImage *) captureImage; +- (NSString *) captureBase64PngImage; @end diff --git a/src/NSView+FrankImageCapture.m b/src/NSView+FrankImageCapture.m index 74af4084..08a7f184 100644 --- a/src/NSView+FrankImageCapture.m +++ b/src/NSView+FrankImageCapture.m @@ -7,6 +7,7 @@ // #import "NSView+FrankImageCapture.h" +#import "DDData.h" @implementation NSView (FrankImageCapture) @@ -30,4 +31,13 @@ - (NSImage *) captureImage{ return [NSView captureImageOfSize:self.bounds.size fromViews:[NSArray arrayWithObject:self]]; } +- (NSString *) captureBase64PngImage { + NSImage* image = [self captureImage]; + if ( image ) { + NSData *imgData = [[[image representations] objectAtIndex:0] representationUsingType:NSPNGFileType properties:nil]; + return [imgData base64Encoded]; + } + return nil; +} + @end From 25d0f0920f2590daeb8a7246e85b08f9f0268b70 Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Tue, 25 Jun 2013 21:39:44 +0900 Subject: [PATCH 03/10] Implement FrankHelper#capture --- gem/lib/frank-cucumber/frank_helper.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gem/lib/frank-cucumber/frank_helper.rb b/gem/lib/frank-cucumber/frank_helper.rb index ce3ece26..26122d97 100644 --- a/gem/lib/frank-cucumber/frank_helper.rb +++ b/gem/lib/frank-cucumber/frank_helper.rb @@ -1,4 +1,5 @@ require 'json' +require 'base64' require 'frank-cucumber/gateway' require 'frank-cucumber/host_scripting' require 'frank-cucumber/wait_helper' @@ -88,6 +89,20 @@ def touch( selector ) touch_successes end + # grab screenshots of all views matching the specified selector. + # @param [String] selector a view selector. + # @return [Array] an array of PNG-image binary. + # @raise an expection if no views matched the selector + # @raise an expection if no views which matched the selector could be capture + def capture( selector ) + images = frankly_map( selector, 'captureBase64PngImage' ) + raise "could not find anything matching [#{selector}] to capture" if images.empty? + raise "some views could not be capture image (probably because they are not within the current viewport)" if images.include?(nil) + images.map do |base64png| + Base64.decode64( base64png ) + end + end + # Fill in text in a text field. # # @param [String] the placeholder text for the desired text field From e05604b52f9ee3fd168eda2147328711d2d380c4 Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Wed, 3 Jul 2013 00:30:34 +0900 Subject: [PATCH 04/10] Check representations is not empty. --- src/NSView+FrankImageCapture.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NSView+FrankImageCapture.m b/src/NSView+FrankImageCapture.m index 08a7f184..bea8358c 100644 --- a/src/NSView+FrankImageCapture.m +++ b/src/NSView+FrankImageCapture.m @@ -33,7 +33,7 @@ - (NSImage *) captureImage{ - (NSString *) captureBase64PngImage { NSImage* image = [self captureImage]; - if ( image ) { + if ( image && [image representations].count>0 ) { NSData *imgData = [[[image representations] objectAtIndex:0] representationUsingType:NSPNGFileType properties:nil]; return [imgData base64Encoded]; } From 43e06af550b44ac59d3c9548067f63eab3d54631 Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Wed, 3 Jul 2013 08:56:10 +0900 Subject: [PATCH 05/10] Update NSView+FrankImageCapture.m --- src/NSView+FrankImageCapture.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NSView+FrankImageCapture.m b/src/NSView+FrankImageCapture.m index bea8358c..5c7167ff 100644 --- a/src/NSView+FrankImageCapture.m +++ b/src/NSView+FrankImageCapture.m @@ -33,7 +33,7 @@ - (NSImage *) captureImage{ - (NSString *) captureBase64PngImage { NSImage* image = [self captureImage]; - if ( image && [image representations].count>0 ) { + if ( image && ([image representations].count>0) ) { NSData *imgData = [[[image representations] objectAtIndex:0] representationUsingType:NSPNGFileType properties:nil]; return [imgData base64Encoded]; } From 68b719e952543b2ad471d233107f8fbd0dd64ecf Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Wed, 3 Jul 2013 21:52:48 +0900 Subject: [PATCH 06/10] Separate the call of GLKView#snapshot from UIView#captureImage. And add depends. --- Frank.xcodeproj/project.pbxproj | 12 ++++++++++++ gem/frank-skeleton/frankify.xcconfig.tt | 2 +- src/GLKView+ImageCapture.h | 14 ++++++++++++++ src/GLKView+ImageCapture.m | 16 ++++++++++++++++ src/UIView+ImageCapture.m | 4 ---- 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/GLKView+ImageCapture.h create mode 100644 src/GLKView+ImageCapture.m diff --git a/Frank.xcodeproj/project.pbxproj b/Frank.xcodeproj/project.pbxproj index 25edde59..57386b9c 100644 --- a/Frank.xcodeproj/project.pbxproj +++ b/Frank.xcodeproj/project.pbxproj @@ -74,6 +74,9 @@ 4C1DD76D12BADFE100E10B8C /* OrientationCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1DD76912BADFE100E10B8C /* OrientationCommand.h */; }; 4C1DD76E12BADFE100E10B8C /* AppCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1DD76A12BADFE100E10B8C /* AppCommand.m */; }; 4C1DD76F12BADFE100E10B8C /* AppCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1DD76B12BADFE100E10B8C /* AppCommand.h */; }; + 52B355C717844C2700060740 /* GLKView+ImageCapture.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B355C517844C2700060740 /* GLKView+ImageCapture.h */; }; + 52B355C817844C2700060740 /* GLKView+ImageCapture.m in Sources */ = {isa = PBXBuildFile; fileRef = 52B355C617844C2700060740 /* GLKView+ImageCapture.m */; }; + 52B355CB17844DA400060740 /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52B355CA17844DA400060740 /* GLKit.framework */; }; 65DBDD7416A89CCA007D3D43 /* GCDAsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = AB7947C115C4418700052B74 /* GCDAsyncSocket.m */; }; 65DBDD8D16A89CCA007D3D43 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; 65DBDDA816A89CDC007D3D43 /* DDAbstractDatabaseLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = ABA9E4BB15C81E7900112290 /* DDAbstractDatabaseLogger.m */; }; @@ -316,6 +319,9 @@ 4C1DD76912BADFE100E10B8C /* OrientationCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrientationCommand.h; sourceTree = ""; }; 4C1DD76A12BADFE100E10B8C /* AppCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppCommand.m; sourceTree = ""; }; 4C1DD76B12BADFE100E10B8C /* AppCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppCommand.h; sourceTree = ""; }; + 52B355C517844C2700060740 /* GLKView+ImageCapture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GLKView+ImageCapture.h"; sourceTree = ""; }; + 52B355C617844C2700060740 /* GLKView+ImageCapture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GLKView+ImageCapture.m"; sourceTree = ""; }; + 52B355CA17844DA400060740 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; }; 65DBDD9216A89CCA007D3D43 /* libCocoaAsyncSocket.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCocoaAsyncSocket.a; sourceTree = BUILT_PRODUCTS_DIR; }; 65DBDDB516A89CDC007D3D43 /* libCocoaLumberjack.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCocoaLumberjack.a; sourceTree = BUILT_PRODUCTS_DIR; }; 65DBDDDA16A89E5B007D3D43 /* libCocoaAsyncSocketMac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCocoaAsyncSocketMac.a; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -489,6 +495,7 @@ AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */, D629938011AB2DF300CE0FB0 /* UIKit.framework in Frameworks */, 00E864C5161D708B00E01209 /* MapKit.framework in Frameworks */, + 52B355CB17844DA400060740 /* GLKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -517,6 +524,7 @@ 305CA7A31642063E00C4ACE5 /* Foundation.framework */, C18A5F20160D572300DC25F6 /* libPublicAutomation.a */, 00E864C4161D708B00E01209 /* MapKit.framework */, + 52B355CA17844DA400060740 /* GLKit.framework */, 08FB77AEFE84172EC02AAC07 /* src */, D629926711AB2CF700CE0FB0 /* lib */, 0867D69AFE84028FC02AAC07 /* Frameworks */, @@ -757,6 +765,8 @@ D6A1D27E15A8D05E00EC056C /* UIView+Frank.m */, C18A5EF3160D4AD300DC25F6 /* UIView+ImageCapture.h */, C18A5EF4160D4AD300DC25F6 /* UIView+ImageCapture.m */, + 52B355C517844C2700060740 /* GLKView+ImageCapture.h */, + 52B355C617844C2700060740 /* GLKView+ImageCapture.m */, C9605E661606BF8E00170F88 /* UIView+MapKitWorkaround.m */, C18A5F1D160D547A00DC25F6 /* UIView+PublicAutomation.m */, 387BFA7C17036DDA007B9F17 /* UISlider+PublicAutomation.m */, @@ -865,6 +875,7 @@ 303CFCE416C80B830004BD05 /* DeviceCommand.h in Headers */, 30E82E3217128AB500E5BC7C /* ResolutionCommand.h in Headers */, 0626BFAE174300240020B33B /* DumpCommandRoute.h in Headers */, + 52B355C717844C2700060740 /* GLKView+ImageCapture.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1238,6 +1249,7 @@ 30E82E3417128AB500E5BC7C /* ResolutionCommand.m in Sources */, 387BFA7D17036DDA007B9F17 /* UISlider+PublicAutomation.m in Sources */, 0626BFAF174300240020B33B /* DumpCommandRoute.m in Sources */, + 52B355C817844C2700060740 /* GLKView+ImageCapture.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/gem/frank-skeleton/frankify.xcconfig.tt b/gem/frank-skeleton/frankify.xcconfig.tt index 8571ec66..6e12461b 100644 --- a/gem/frank-skeleton/frankify.xcconfig.tt +++ b/gem/frank-skeleton/frankify.xcconfig.tt @@ -1,6 +1,6 @@ INSTALL_PATH = /./ -FRANK_CORE_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -lShelley -lFrank <%= @libs.map { |lib| "-l#{lib}" }.join(' ') %> +FRANK_CORE_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -framework GLKit -lShelley -lFrank <%= @libs.map { |lib| "-l#{lib}" }.join(' ') %> FRANK_CORE_MAC_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -lShelleyMac -lFrankMac <%= @libsMac.map { |lib| "-l#{lib}" }.join(' ') %> FRANK_CORE_GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = FRANKIFIED diff --git a/src/GLKView+ImageCapture.h b/src/GLKView+ImageCapture.h new file mode 100644 index 00000000..4a56c614 --- /dev/null +++ b/src/GLKView+ImageCapture.h @@ -0,0 +1,14 @@ +// +// GLKView+ImageCapture.h +// Frank +// +// Created by Toshiyuki Suzumura on 2013/07/03. +// + +#import + +@interface GLKView (ImageCapture) + +- (UIImage *)captureImage; + +@end diff --git a/src/GLKView+ImageCapture.m b/src/GLKView+ImageCapture.m new file mode 100644 index 00000000..1b4822db --- /dev/null +++ b/src/GLKView+ImageCapture.m @@ -0,0 +1,16 @@ +// +// GLKView+ImageCapture.m +// Frank +// +// Created by Toshiyuki Suzumura on 2013/07/03. +// + +#import "GLKView+ImageCapture.h" + +@implementation GLKView (ImageCapture) + +- (UIImage*)captureImage { + return [self snapshot]; +} + +@end diff --git a/src/UIView+ImageCapture.m b/src/UIView+ImageCapture.m index a2d0cc72..bc215b92 100644 --- a/src/UIView+ImageCapture.m +++ b/src/UIView+ImageCapture.m @@ -13,10 +13,6 @@ @implementation UIView (ImageCapture) - (UIImage *)captureImage { - if ([self respondsToSelector:@selector(snapshot)]) { - return [self performSelector:@selector(snapshot)]; - } - UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; From a46dbb40cbd58741b3c800780eccd3ae04c5c75d Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Thu, 4 Jul 2013 21:20:00 +0900 Subject: [PATCH 07/10] Remove captureBase64PngImage from UIVew and NSView. --- src/NSView+FrankImageCapture.h | 1 - src/NSView+FrankImageCapture.m | 10 ---------- src/UIView+ImageCapture.h | 1 - src/UIView+ImageCapture.m | 10 ---------- 4 files changed, 22 deletions(-) diff --git a/src/NSView+FrankImageCapture.h b/src/NSView+FrankImageCapture.h index b6fcd906..acb3bac0 100644 --- a/src/NSView+FrankImageCapture.h +++ b/src/NSView+FrankImageCapture.h @@ -12,6 +12,5 @@ + (NSImage *) captureImageOfSize:(CGSize)size fromViews:(NSArray *)views; - (NSImage *) captureImage; -- (NSString *) captureBase64PngImage; @end diff --git a/src/NSView+FrankImageCapture.m b/src/NSView+FrankImageCapture.m index 5c7167ff..74af4084 100644 --- a/src/NSView+FrankImageCapture.m +++ b/src/NSView+FrankImageCapture.m @@ -7,7 +7,6 @@ // #import "NSView+FrankImageCapture.h" -#import "DDData.h" @implementation NSView (FrankImageCapture) @@ -31,13 +30,4 @@ - (NSImage *) captureImage{ return [NSView captureImageOfSize:self.bounds.size fromViews:[NSArray arrayWithObject:self]]; } -- (NSString *) captureBase64PngImage { - NSImage* image = [self captureImage]; - if ( image && ([image representations].count>0) ) { - NSData *imgData = [[[image representations] objectAtIndex:0] representationUsingType:NSPNGFileType properties:nil]; - return [imgData base64Encoded]; - } - return nil; -} - @end diff --git a/src/UIView+ImageCapture.h b/src/UIView+ImageCapture.h index 4bea8bd9..bbbd2681 100644 --- a/src/UIView+ImageCapture.h +++ b/src/UIView+ImageCapture.h @@ -11,6 +11,5 @@ @interface UIView (ImageCapture) - (UIImage *)captureImage; -- (NSString *)captureBase64PngImage; @end diff --git a/src/UIView+ImageCapture.m b/src/UIView+ImageCapture.m index bc215b92..692a8fa8 100644 --- a/src/UIView+ImageCapture.m +++ b/src/UIView+ImageCapture.m @@ -8,7 +8,6 @@ #import "UIView+ImageCapture.h" #import -#import "DDData.h" @implementation UIView (ImageCapture) @@ -23,13 +22,4 @@ - (UIImage *)captureImage { return image; } -- (NSString *)captureBase64PngImage { - UIImage* image = [self captureImage]; - if ( image ) { - NSData *imgData = UIImagePNGRepresentation(image); - return [imgData base64Encoded]; - } - return nil; -} - @end From 207e285f4f281cae6abdf5689b064d6c527acaf0 Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Thu, 4 Jul 2013 21:21:31 +0900 Subject: [PATCH 08/10] Implement FEX_UID for UIVew and NSView. --- Frank.xcodeproj/project.pbxproj | 12 ++++++++++++ src/NSView+Frank.h | 14 ++++++++++++++ src/NSView+Frank.m | 16 ++++++++++++++++ src/UIView+Frank.h | 14 ++++++++++++++ src/UIView+Frank.m | 6 +++++- 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/NSView+Frank.h create mode 100644 src/NSView+Frank.m create mode 100644 src/UIView+Frank.h diff --git a/Frank.xcodeproj/project.pbxproj b/Frank.xcodeproj/project.pbxproj index 57386b9c..491d6593 100644 --- a/Frank.xcodeproj/project.pbxproj +++ b/Frank.xcodeproj/project.pbxproj @@ -74,6 +74,9 @@ 4C1DD76D12BADFE100E10B8C /* OrientationCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1DD76912BADFE100E10B8C /* OrientationCommand.h */; }; 4C1DD76E12BADFE100E10B8C /* AppCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1DD76A12BADFE100E10B8C /* AppCommand.m */; }; 4C1DD76F12BADFE100E10B8C /* AppCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1DD76B12BADFE100E10B8C /* AppCommand.h */; }; + 520C60F617858EB9003D2535 /* NSView+Frank.m in Sources */ = {isa = PBXBuildFile; fileRef = 520C60F417858EB9003D2535 /* NSView+Frank.m */; }; + 520C60F917858FD7003D2535 /* NSView+Frank.h in Headers */ = {isa = PBXBuildFile; fileRef = 520C60F817858FD7003D2535 /* NSView+Frank.h */; }; + 520C60FB1785901D003D2535 /* UIView+Frank.h in Headers */ = {isa = PBXBuildFile; fileRef = 520C60FA1785901D003D2535 /* UIView+Frank.h */; }; 52B355C717844C2700060740 /* GLKView+ImageCapture.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B355C517844C2700060740 /* GLKView+ImageCapture.h */; }; 52B355C817844C2700060740 /* GLKView+ImageCapture.m in Sources */ = {isa = PBXBuildFile; fileRef = 52B355C617844C2700060740 /* GLKView+ImageCapture.m */; }; 52B355CB17844DA400060740 /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52B355CA17844DA400060740 /* GLKit.framework */; }; @@ -319,6 +322,9 @@ 4C1DD76912BADFE100E10B8C /* OrientationCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrientationCommand.h; sourceTree = ""; }; 4C1DD76A12BADFE100E10B8C /* AppCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppCommand.m; sourceTree = ""; }; 4C1DD76B12BADFE100E10B8C /* AppCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppCommand.h; sourceTree = ""; }; + 520C60F417858EB9003D2535 /* NSView+Frank.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSView+Frank.m"; sourceTree = ""; }; + 520C60F817858FD7003D2535 /* NSView+Frank.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSView+Frank.h"; sourceTree = ""; }; + 520C60FA1785901D003D2535 /* UIView+Frank.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Frank.h"; sourceTree = ""; }; 52B355C517844C2700060740 /* GLKView+ImageCapture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GLKView+ImageCapture.h"; sourceTree = ""; }; 52B355C617844C2700060740 /* GLKView+ImageCapture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GLKView+ImageCapture.m"; sourceTree = ""; }; 52B355CA17844DA400060740 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; }; @@ -762,6 +768,7 @@ children = ( C9605E681606BFAE00170F88 /* UIImage+Frank.h */, C9605E691606BFAE00170F88 /* UIImage+Frank.m */, + 520C60FA1785901D003D2535 /* UIView+Frank.h */, D6A1D27E15A8D05E00EC056C /* UIView+Frank.m */, C18A5EF3160D4AD300DC25F6 /* UIView+ImageCapture.h */, C18A5EF4160D4AD300DC25F6 /* UIView+ImageCapture.m */, @@ -777,6 +784,8 @@ 302B803F1646DE02000F9861 /* NSImage+Frank.h */, 302B80401646DE02000F9861 /* NSImage+Frank.m */, 303A751116702D3D00B93673 /* NSObject+FrankAutomation.m */, + 520C60F817858FD7003D2535 /* NSView+Frank.h */, + 520C60F417858EB9003D2535 /* NSView+Frank.m */, 30412D2E165333E300719CD2 /* NSView+FrankImageCapture.h */, 30412D2F165333E300719CD2 /* NSView+FrankImageCapture.m */, ); @@ -832,6 +841,7 @@ C189EF1F16BB5A8100F8236D /* VersionCommand.h in Headers */, 303CFCE516C80B830004BD05 /* DeviceCommand.h in Headers */, 30E82E3317128AB500E5BC7C /* ResolutionCommand.h in Headers */, + 520C60F917858FD7003D2535 /* NSView+Frank.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -876,6 +886,7 @@ 30E82E3217128AB500E5BC7C /* ResolutionCommand.h in Headers */, 0626BFAE174300240020B33B /* DumpCommandRoute.h in Headers */, 52B355C717844C2700060740 /* GLKView+ImageCapture.h in Headers */, + 520C60FB1785901D003D2535 /* UIView+Frank.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1120,6 +1131,7 @@ C189EF2116BB5A8100F8236D /* VersionCommand.m in Sources */, 303CFCE716C80B830004BD05 /* DeviceCommand.m in Sources */, 30E82E3517128AB500E5BC7C /* ResolutionCommand.m in Sources */, + 520C60F617858EB9003D2535 /* NSView+Frank.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/NSView+Frank.h b/src/NSView+Frank.h new file mode 100644 index 00000000..dec81151 --- /dev/null +++ b/src/NSView+Frank.h @@ -0,0 +1,14 @@ +// +// NSView+Frank.h +// Frank +// +// Created by Toshiyuki Suzumura on 2013/07/04. +// + +#import + +@interface NSView (Frank) + +- (NSString *) FEX_UID; + +@end diff --git a/src/NSView+Frank.m b/src/NSView+Frank.m new file mode 100644 index 00000000..a9fe5b73 --- /dev/null +++ b/src/NSView+Frank.m @@ -0,0 +1,16 @@ +// +// NSView+Frank.m +// Frank +// +// Created by Toshiyuki Suzumura on 2013/07/04. +// + +#import "NSView+Frank.h" + +@implementation NSView (Frank) + +- (NSString *) FEX_UID { + return [NSString stringWithFormat:@"%lu",(uintptr_t)self]; +} + +@end diff --git a/src/UIView+Frank.h b/src/UIView+Frank.h new file mode 100644 index 00000000..db29877d --- /dev/null +++ b/src/UIView+Frank.h @@ -0,0 +1,14 @@ +// +// UIView+Frank.h +// Frank +// +// Created by Toshiyuki Suzumura on 2013/07/04. +// + +#import + +@interface UIView (Frank) + +- (NSString *) FEX_UID; + +@end diff --git a/src/UIView+Frank.m b/src/UIView+Frank.m index d4203415..54be2932 100644 --- a/src/UIView+Frank.m +++ b/src/UIView+Frank.m @@ -6,7 +6,7 @@ // Copyright (c) 2012 ThoughtWorks. All rights reserved. // - +#import "UIView+Frank.h" #import "LoadableCategory.h" MAKE_CATEGORIES_LOADABLE(UIView_Frank) @@ -51,4 +51,8 @@ - (BOOL)FEX_isFullyWithinWindow { return CGRectContainsRect(self.window.bounds, myFrameInWindowCoords); } +- (NSString *) FEX_UID { + return [NSString stringWithFormat:@"%i",(int)self]; +} + @end From 1a434abb5294a2a243ccc3c7201a4b02a5b12a88 Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Thu, 4 Jul 2013 21:23:29 +0900 Subject: [PATCH 09/10] Implement capture method with ImageCaptureRoute and FEX_UID. --- gem/lib/frank-cucumber/frank_helper.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gem/lib/frank-cucumber/frank_helper.rb b/gem/lib/frank-cucumber/frank_helper.rb index 26122d97..010b0755 100644 --- a/gem/lib/frank-cucumber/frank_helper.rb +++ b/gem/lib/frank-cucumber/frank_helper.rb @@ -95,12 +95,17 @@ def touch( selector ) # @raise an expection if no views matched the selector # @raise an expection if no views which matched the selector could be capture def capture( selector ) - images = frankly_map( selector, 'captureBase64PngImage' ) - raise "could not find anything matching [#{selector}] to capture" if images.empty? - raise "some views could not be capture image (probably because they are not within the current viewport)" if images.include?(nil) - images.map do |base64png| - Base64.decode64( base64png ) - end + view_uids = frankly_map( selector, 'FEX_UID' ) + raise "could not find anything matching [#{selector}] to capture" if view_uids.empty? + raise "some views could not be capture image" if view_uids.include?(nil) + + frank_server.send_get( 'screenshot/snapshot-all-views' ) + screenshots = view_uids.map{|uid| + path = "screenshot/view-snapshot/#{uid}" + frank_server.send_get( path ) + } + raise "some views failed to capture image" if screenshots.include?(nil) + screenshots end # Fill in text in a text field. From 0645273f4390273ec562d1fc2b2e1899a8cf5765 Mon Sep 17 00:00:00 2001 From: Toshiyuki Suzumura Date: Thu, 4 Jul 2013 21:24:27 +0900 Subject: [PATCH 10/10] Modify to use FEX_UID to build uid-string. --- src/ImageCaptureRoute.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ImageCaptureRoute.m b/src/ImageCaptureRoute.m index 6a62b68e..cc240c53 100644 --- a/src/ImageCaptureRoute.m +++ b/src/ImageCaptureRoute.m @@ -14,9 +14,11 @@ #if TARGET_OS_IPHONE #import "UIImage+Frank.h" +#import "UIView+Frank.h" #import "UIView+ImageCapture.h" #else #import "NSImage+Frank.h" +#import "NSView+Frank.h" #import "NSView+FrankImageCapture.h" #endif #import "FranklyProtocolHelper.h" @@ -49,7 +51,7 @@ - (void) snapshotView:(UIView *)view{ UIImage *image = [view captureImage]; NSData *imgData = UIImagePNGRepresentation(image); - NSString *viewUID = [NSString stringWithFormat:@"%i",(int)view]; + NSString *viewUID = [view FEX_UID]; [imgData writeToFile:[self pathForSnapshotOfViewWithUID:viewUID] atomically:NO]; } #else @@ -57,7 +59,7 @@ - (void) snapshotView:(NSView *)view{ NSImage *image = [view captureImage]; NSData *imgData = [[[image representations] objectAtIndex:0] representationUsingType:NSPNGFileType properties:nil]; - NSString *viewUID = [NSString stringWithFormat:@"%lu",(uintptr_t)view]; + NSString *viewUID = [view FEX_UID]; [imgData writeToFile:[self pathForSnapshotOfViewWithUID:viewUID] atomically:NO]; } #endif