Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial press and bring_to_front implementation for Mac

  • Loading branch information...
commit 072da5d501cea1789b60db23fbb271dac42e0fc5 1 parent 930cfef
@MichaelBuckley MichaelBuckley authored
View
2  Frank.xcodeproj/project.pbxproj
@@ -66,6 +66,7 @@
30C544B2167E4D9E0034F49C /* SuccessCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C544AF167E4D9E0034F49C /* SuccessCommand.h */; };
30C544B3167E4D9E0034F49C /* SuccessCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C544B0167E4D9E0034F49C /* SuccessCommand.m */; };
30C544B4167E4D9E0034F49C /* SuccessCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C544B0167E4D9E0034F49C /* SuccessCommand.m */; };
+ 30C9352716A5261800A4BFD1 /* MapOperationCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = D6D05CA811C883AA0081C5A5 /* MapOperationCommand.m */; };
4C1DD76C12BADFE100E10B8C /* OrientationCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1DD76812BADFE100E10B8C /* OrientationCommand.m */; };
4C1DD76D12BADFE100E10B8C /* OrientationCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C1DD76912BADFE100E10B8C /* OrientationCommand.h */; };
4C1DD76E12BADFE100E10B8C /* AppCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1DD76A12BADFE100E10B8C /* AppCommand.m */; };
@@ -873,6 +874,7 @@
30228E241642161200B1F9E7 /* DumpCommand.m in Sources */,
30228E261642161200B1F9E7 /* EnginesCommand.m in Sources */,
30228E281642161200B1F9E7 /* ExitCommand.m in Sources */,
+ 30C9352716A5261800A4BFD1 /* MapOperationCommand.m in Sources */,
30AC65A8165C3A4D00DEB0AB /* OSXKeyboardCommand.m in Sources */,
306249F91644E68C00E8C20A /* FrankCommandRoute.m in Sources */,
306249FB1644E68C00E8C20A /* ImageCaptureRoute.m in Sources */,
View
2  gem/frank-skeleton/frankify.xcconfig.tt
@@ -1,5 +1,5 @@
INSTALL_PATH = /./
FRANK_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -lShelley <%= @without_http_server ? "" : "-lCocoaHTTPServer" %> -lFrank
-FRANK_MAC_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -LFrank <%= @without_http_server ? "" : "-lCocoaHTTPServerMac" %> -lFrankMac
+FRANK_MAC_LDFLAGS = -all_load -ObjC -framework CFNetwork -framework Security -lShelleyMac <%= @without_http_server ? "" : "-lCocoaHTTPServerMac" %> -lFrankMac
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = FRANKIFIED
View
BIN  gem/frank-skeleton/libFrankMac.a
Binary file not shown
View
BIN  gem/frank-skeleton/libShelleyMac.a
Binary file not shown
View
2  gem/lib/frank-cucumber.rb
@@ -1,7 +1,9 @@
require 'frank-cucumber/rect'
require 'frank-cucumber/color_helper'
require 'frank-cucumber/frank_helper'
+require 'frank-cucumber/frank_mac_helper'
require 'frank-cucumber/launcher'
+require 'frank-cucumber/mac_launcher'
World(Frank::Cucumber::ColorHelper)
World(Frank::Cucumber::FrankHelper)
View
2  gem/lib/frank-cucumber/cli.rb
@@ -37,7 +37,7 @@ def setup
desc "update", "updates the frank server components inside your Frank directory"
long_desc "This updates the parts of Frank that are embedded inside your app (e.g. libFrank.a and frank_static_resources.bundle)"
def update
- %w{libFrank.a libCocoaHTTPServer.a libShelley.a libFrankMac.a libCocoaHTTPServerMac.a}.each do |f|
+ %w{libFrank.a libCocoaHTTPServer.a libShelley.a libFrankMac.a libCocoaHTTPServerMac.a libShelleyMac.a}.each do |f|
copy_file f, File.join( 'Frank', f ), :force => true
end
directory( 'frank_static_resources.bundle', 'Frank/frank_static_resources.bundle', :force => true )
View
3  gem/lib/frank-cucumber/console.rb
@@ -1,11 +1,12 @@
require 'frank-cucumber/frank_helper'
+require 'frank-cucumber/frank_mac_helper'
require 'frank-cucumber/launcher'
module Frank
class Console
include Frank::Cucumber::FrankHelper
include Frank::Cucumber::Launcher
-
+
def check_for_running_app
print 'connecting to app...'
begin
View
23 gem/lib/frank-cucumber/frank_mac_helper.rb
@@ -0,0 +1,23 @@
+require 'frank-cucumber/frank_helper'
+
+module Frank module Cucumber
+
+module FrankHelper
+
+ def press( selector )
+ touch_successes = frankly_map( selector, 'FEX_press' )
+ raise "could not find anything matching [#{selector}] to press" if touch_successes == nil or touch_successes.empty?
+ raise "some objects do not support the press action" if touch_successes.include?(false)
+ end
+
+ def bring_to_front( selector )
+ touch_successes = frankly_map( selector, 'FEX_raise' )
+ raise "could not find anything matching [#{selector}] to bring to the front" if touch_successes == nil or touch_successes.empty?
+ raise "some objects do not support the bring to front action" if touch_successes.include?(false)
+ end
+
+end
+
+end
+
+end
View
5 src/FrankServer.m
@@ -19,9 +19,9 @@
#import "AccessibilityCheckCommand.h"
#import "EnginesCommand.h"
#import "SuccessCommand.h"
+#import "MapOperationCommand.h"
#if TARGET_OS_IPHONE
-#import "MapOperationCommand.h"
#import "OrientationCommand.h"
#import "LocationCommand.h"
#import "IOSKeyboardCommand.h"
@@ -53,14 +53,13 @@ - (id) initWithStaticFrankBundleNamed:(NSString *)bundleName
[frankCommandRoute registerCommand:[[[AppCommand alloc] init]autorelease] withName:@"app_exec"];
[frankCommandRoute registerCommand:[[[EnginesCommand alloc] init]autorelease] withName:@"engines"];
[frankCommandRoute registerCommand:[[[ExitCommand alloc] init] autorelease] withName:@"exit"];
+ [frankCommandRoute registerCommand:[[[MapOperationCommand alloc]init]autorelease] withName:@"map"];
#if TARGET_OS_IPHONE
- [frankCommandRoute registerCommand:[[[MapOperationCommand alloc]init]autorelease] withName:@"map"];
[frankCommandRoute registerCommand:[[[OrientationCommand alloc]init]autorelease] withName:@"orientation"];
[frankCommandRoute registerCommand:[[[LocationCommand alloc]init]autorelease] withName:@"location"];
[frankCommandRoute registerCommand:[[[IOSKeyboardCommand alloc] init]autorelease] withName:@"type_into_keyboard"];
#else
- [frankCommandRoute registerCommand:[[[SuccessCommand alloc]init]autorelease] withName:@"map"];
[frankCommandRoute registerCommand:[[[SuccessCommand alloc]init]autorelease] withName:@"orientation"];
[frankCommandRoute registerCommand:[[[SuccessCommand alloc]init]autorelease] withName:@"location"];
[frankCommandRoute registerCommand:[[[OSXKeyboardCommand alloc] init]autorelease] withName:@"type_into_keyboard"];
View
11 src/MapOperationCommand.m
@@ -18,9 +18,16 @@
#import "Operation.h"
#import "DumpCommand.h"
+#if TARGET_OS_IPHONE
+#define FrankMapViewType UIView
+#else
+#define FrankMapViewType NSView
+#endif
+
+
@implementation MapOperationCommand
-- (id) performOperation:(Operation *)operation onView:(UIView *)view {
+- (id) performOperation:(Operation *)operation onView:(FrankMapViewType *)view {
if( [operation appliesToObject:view] )
return [operation applyToObject:view];
@@ -49,7 +56,7 @@ - (NSString *)handleCommandWithRequestBody:(NSString *)requestBody {
}
NSMutableArray *results = [NSMutableArray arrayWithCapacity:[viewsToMap count]];
- for (UIView *view in viewsToMap) {
+ for (FrankMapViewType *view in viewsToMap) {
@try {
id result = [self performOperation:operation onView:view];
[results addObject:[ViewJSONSerializer jsonify:result]];
View
79 src/NSObject+FrankAutomation.m
@@ -28,7 +28,7 @@ - (NSString *) FEX_accessibilityLabel {
if ([[self accessibilityAttributeNames] containsObject: candidateAttribute])
{
id value = [self accessibilityAttributeValue: candidateAttribute];
-
+
if ([value isKindOfClass: [NSString class]]) {
returnValue = value;
break;
@@ -52,12 +52,12 @@ - (CGRect) FEX_accessibilityFrame {
{
if ([[self accessibilityAttributeNames] containsObject: NSAccessibilityPositionAttribute])
{
- [self accessibilityAttributeValue: NSAccessibilityPositionAttribute];
+ originValue = [self accessibilityAttributeValue: NSAccessibilityPositionAttribute];
}
if ([[self accessibilityAttributeNames] containsObject: NSAccessibilitySizeAttribute])
{
- [self accessibilityAttributeValue: NSAccessibilitySizeAttribute];
+ sizeValue = [self accessibilityAttributeValue: NSAccessibilitySizeAttribute];
}
}
@@ -73,4 +73,77 @@ - (CGRect) FEX_accessibilityFrame {
return CGRectMake(origin.x, origin.y, size.width, size.height);
}
+- (BOOL) FEX_performAccessibilityAction: (NSString*) anAction
+{
+ BOOL returnValue = NO;
+
+ if ([[self accessibilityActionNames] containsObject: anAction])
+ {
+ [self accessibilityPerformAction: anAction];
+ returnValue = YES;
+ }
+
+ return returnValue;
+}
+
+- (BOOL) FEX_press
+{
+ return [self FEX_performAccessibilityAction: NSAccessibilityPressAction];
+}
+
+- (BOOL) FEX_raise
+{
+ return [self FEX_performAccessibilityAction: NSAccessibilityRaiseAction];
+}
+
+@end
+
+@implementation NSApplication (FrankAutomation)
+
+- (BOOL) FEX_raise
+{
+ [self activateIgnoringOtherApps: YES];
+ return YES;
+}
+
+@end
+
+@implementation NSControl (FrankAutomation)
+
+- (NSString*) FEX_accessibilityLabel
+{
+ NSString* returnValue = [[self cell] FEX_accessibilityLabel];
+
+ if (returnValue == nil)
+ {
+ returnValue = [super FEX_accessibilityLabel];
+ }
+
+ return returnValue;
+}
+
+- (CGRect) FEX_accessibilityFrame
+{
+ CGRect returnValue = [[self cell] FEX_accessibilityFrame];
+
+ if (NSEqualRects(returnValue, NSZeroRect))
+ {
+ returnValue = [super FEX_accessibilityFrame];
+ }
+
+ return returnValue;
+}
+
+- (BOOL) FEX_performAccessibilityAction: (NSString*) anAction
+{
+ BOOL returnValue = [[self cell] FEX_performAccessibilityAction: anAction];
+
+ if (returnValue == NO)
+ {
+ returnValue = [super FEX_performAccessibilityAction: anAction];
+ }
+
+ return returnValue;
+}
+
@end
View
14 src/ViewJSONSerializer.m
@@ -124,7 +124,7 @@ + (id) extractInstanceFromValue:(NSValue *)value {
// Numbers just passthrough
if([value isKindOfClass: NSNumber.class]) {
- if(isinf([value doubleValue])) return PSEUDO_INF;
+ if(isinf([(NSNumber*) value doubleValue])) return PSEUDO_INF;
return value;
}
@@ -144,7 +144,11 @@ + (id) extractInstanceFromValue:(NSValue *)value {
};
if(strcmp(@encode(CGRect), objcType) == 0) {
+#if TARGET_OS_IPHONE
CGRect rawRect = [value CGRectValue];
+#else
+ CGRect rawRect = [value rectValue];
+#endif
return [NSDictionary dictionaryWithObjectsAndKeys:
convertCGPoint(rawRect.origin), @"origin",
@@ -154,13 +158,21 @@ + (id) extractInstanceFromValue:(NSValue *)value {
if(strcmp(@encode(CGSize), objcType) == 0) {
+#if TARGET_OS_IPHONE
CGSize rawSize = [value CGSizeValue];
+#else
+ CGSize rawSize = [value sizeValue];
+#endif
return convertCGSize(rawSize);
}
if(strcmp(@encode(CGPoint), objcType) == 0) {
+#if TARGET_OS_IPHONE
CGPoint point = [value CGPointValue];
+#else
+ CGPoint point = [value pointValue];
+#endif
return convertCGPoint(point);
}
Please sign in to comment.
Something went wrong with that request. Please try again.