diff --git a/Frank.xcodeproj/project.pbxproj b/Frank.xcodeproj/project.pbxproj index 25edde59..491d6593 100644 --- a/Frank.xcodeproj/project.pbxproj +++ b/Frank.xcodeproj/project.pbxproj @@ -74,6 +74,12 @@ 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 */; }; 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 +322,12 @@ 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; }; 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 +501,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 +530,7 @@ 305CA7A31642063E00C4ACE5 /* Foundation.framework */, C18A5F20160D572300DC25F6 /* libPublicAutomation.a */, 00E864C4161D708B00E01209 /* MapKit.framework */, + 52B355CA17844DA400060740 /* GLKit.framework */, 08FB77AEFE84172EC02AAC07 /* src */, D629926711AB2CF700CE0FB0 /* lib */, 0867D69AFE84028FC02AAC07 /* Frameworks */, @@ -754,9 +768,12 @@ 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 */, + 52B355C517844C2700060740 /* GLKView+ImageCapture.h */, + 52B355C617844C2700060740 /* GLKView+ImageCapture.m */, C9605E661606BF8E00170F88 /* UIView+MapKitWorkaround.m */, C18A5F1D160D547A00DC25F6 /* UIView+PublicAutomation.m */, 387BFA7C17036DDA007B9F17 /* UISlider+PublicAutomation.m */, @@ -767,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 */, ); @@ -822,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; }; @@ -865,6 +885,8 @@ 303CFCE416C80B830004BD05 /* DeviceCommand.h in Headers */, 30E82E3217128AB500E5BC7C /* ResolutionCommand.h in Headers */, 0626BFAE174300240020B33B /* DumpCommandRoute.h in Headers */, + 52B355C717844C2700060740 /* GLKView+ImageCapture.h in Headers */, + 520C60FB1785901D003D2535 /* UIView+Frank.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1109,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; }; @@ -1238,6 +1261,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/gem/lib/frank-cucumber/frank_helper.rb b/gem/lib/frank-cucumber/frank_helper.rb index ce3ece26..010b0755 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,25 @@ 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 ) + 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. # # @param [String] the placeholder text for the desired text field 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/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 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