Skip to content
Browse files

merge in changes from server branch

  • Loading branch information...
2 parents 70167c5 + 731b559 commit 8ebfd4393361e2de146feb6c4793fd5d261aec3a @krukow krukow committed
View
97 calabash/Classes/CalabashLoader.m
@@ -26,7 +26,7 @@ @implementation CalabashLoader
+ (void)applicationDidBecomeActive:(NSNotification *)notification {
[SelectorEngineRegistry registerSelectorEngine:[[CalabashUISpecSelectorEngine alloc] init] WithName:@"calabash_uispec"];
- NSLog(@"Calabash 0.9.200 registered with Frank as selector engine named 'calabash_uispec'");
+ NSLog(@"Calabash %@ registered with Frank as selector engine named 'calabash_uispec'",kLPCALABASHVERSION);
LPRecordRoute *recordRoute = [LPRecordRoute new];
@@ -57,99 +57,4 @@ + (void)load {
}
-/*
-- (id) init
-{
- self = [super init];
- if (self != nil) {
-
- LPMapRoute* mr = [LPMapRoute new];
- [LPRouter addRoute:mr forPath:@"map"];
- [mr release];
- LPScreenshotRoute *sr =[LPScreenshotRoute new];
- [LPRouter addRoute:sr forPath:@"screenshot"];
- [sr release];
-
- LPRecordRoute *rr =[LPRecordRoute new];
- [LPRouter addRoute:rr forPath:@"record"];
- [rr release];
-
-// LPPlaybackRoute *pr =[LPPlaybackRoute new];
-// [LPRouter addRoute:pr forPath:@"/play"];
-// [pr release];
-//
- LPAsyncPlaybackRoute *apr =[LPAsyncPlaybackRoute new];
- [LPRouter addRoute:apr forPath:@"play"];
- [apr release];
-
- LPUserPrefRoute *bgr =[LPUserPrefRoute new];
- [LPRouter addRoute:bgr forPath:@"userprefs"];
- [bgr release];
-
- LPInterpolateRoute *panr =[LPInterpolateRoute new];
- [LPRouter addRoute:panr forPath:@"interpolate"];
- [panr release];
-
- LPBackdoorRoute* backdr = [LPBackdoorRoute new];
- [LPRouter addRoute:backdr forPath:@"backdoor"];
- [backdr release];
-
- LPVersionRoute* verr = [LPVersionRoute new];
- [LPRouter addRoute:verr forPath:@"version"];
- [verr release];
-
- LPConditionRoute* cond = [LPConditionRoute new];
- [LPRouter addRoute:cond forPath:@"condition"];
- [cond release];
-
- LPKeyboardRoute* keyboard = [LPKeyboardRoute new];
- [LPRouter addRoute:keyboard forPath:@"keyboard"];
- [keyboard release];
-
- LPUIARoute* uia = [LPUIARoute new];
- [LPRouter addRoute:uia forPath:@"uia"];
- [uia release];
-
-
-
-
-//
-// LPScreencastRoute *scr = [LPScreencastRoute new];
-// [LPRouter addRoute:scr forPath:@"/screencast"];
-// [scr release];
-//
-
- _httpServer = [[[LPHTTPServer alloc]init] retain];
-
- [_httpServer setName:@"Calabash Server"];
- [_httpServer setType:@"_http._tcp."];
-
- // Advertise this device's capabilities to our listeners inside of the TXT record
- NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
- NSMutableDictionary *capabilities = [[NSMutableDictionary alloc]
- initWithObjectsAndKeys:
- [[UIDevice currentDevice] name], @"name",
- [[UIDevice currentDevice] model], @"model",
- [[UIDevice currentDevice] systemVersion], @"os_version",
- [info objectForKey:@"CFBundleDisplayName"], @"app",
- [info objectForKey:@"CFBundleIdentifier"], @"app_id",
- [info objectForKey:@"CFBundleVersion"], @"app_version",
- nil];
- if ([[UIDevice currentDevice] respondsToSelector:@selector(uniqueIdentifier)]) {
- [capabilities setObject:[[UIDevice currentDevice] uniqueIdentifier] forKey:@"uuid"];
- }
-
- [_httpServer setTXTRecordDictionary:capabilities];
- [_httpServer setConnectionClass:[LPRouter class]];
- [_httpServer setPort:37265];
- // Serve files from our embedded Web folder
-// NSString *webPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Web"];
-// [_httpServer setDocumentRoot:webPath];
- NSLog( @"Creating the server: %@", _httpServer );
- }
- return self;
-}
-*/
-
-
@end
View
1 calabash/Classes/FranklyServer/Commands/LPVersionCommand.h
@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
#import "FrankCommandRoute.h"
+static const NSString *kLPCALABASHVERSION = @"1.0.0.pre1";
@interface LPVersionCommand : NSObject<FrankCommand>
View
43 calabash/Classes/FranklyServer/Commands/LPVersionCommand.m
@@ -10,8 +10,6 @@
#import "JSON.h"
#import <sys/utsname.h>
-#define kLPCALABASHVERSION @"0.9.200"
-
@implementation LPVersionCommand
@@ -31,22 +29,51 @@ - (NSString *)handleCommandWithRequestBody:(NSString *)requestBody
if (!nameString)
{
nameString = @"Unknown";
- }
+ }
struct utsname systemInfo;
uname(&systemInfo);
-
+
+ NSString *system = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
+
+ UIDevice *device = [UIDevice currentDevice];
+ NSDictionary *env = [[NSProcessInfo processInfo]environment];
+
+ BOOL inch5Phone = NO;
+ if([@"iPhone Simulator" isEqualToString: [device model]])
+ {
+
+ NSPredicate *inch5PhonePred = [NSPredicate predicateWithFormat:@"IPHONE_SIMULATOR_VERSIONS LIKE '*iPhone (Retina 4-inch)*'"];
+ inch5Phone = [inch5PhonePred evaluateWithObject:env];
+ }
+ else if ([[device model] hasPrefix:@"iPhone"])
+ {
+ inch5Phone = [system isEqualToString:@"iPhone5,2"];
+ }
+
+ NSString *dev = [env objectForKey:@"IPHONE_SIMULATOR_DEVICE"];
+ if (!dev) {
+ dev = @"";
+ }
+
+ NSString *sim = [env objectForKey:@"IPHONE_SIMULATOR_VERSIONS"];
+ if (!sim) {
+ sim = @"";
+ }
+
+
NSDictionary* res = [NSDictionary dictionaryWithObjectsAndKeys:
kLPCALABASHVERSION , @"version",
idString,@"app_id",
[UIDevice currentDevice].systemVersion, @"iOS_version",
nameString,@"app_name",
- [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding], @"system",
+ system, @"system",
+ dev, @"simulator_device",
+ sim, @"simulator",
versionString,@"app_version",
@"SUCCESS",@"outcome",
- //device, os, serial?, other?
+ //device, os, serial?, other?
nil];
- return TO_JSON(res);
-
+ return TO_JSON(res);
}
View
3 calabash/Classes/FranklyServer/Routes/LPAsyncPlaybackRoute.m
@@ -48,9 +48,8 @@ -(void) beginOperation
if (query != nil) {
__block NSArray* result;
dispatch_sync(dispatch_get_main_queue(), ^{
- result = [[LPOperation performQueryAll:query] retain];
+ result = [[LPOperation performQuery:query] retain];
});
-
if ([result count] >0) {
id v = [result objectAtIndex:0];//autopick first?
View
14 calabash/Classes/FranklyServer/Routes/LPExitRoute.h
@@ -0,0 +1,14 @@
+//
+// LPExitRoute.h
+// calabash
+//
+// Created by Trevor Harmon on 11/15/12.
+// Copyright (c) 2012 LessPainful. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "LPRoute.h"
+
+@interface LPExitRoute : NSObject<LPRoute>
+
+@end
View
26 calabash/Classes/FranklyServer/Routes/LPExitRoute.m
@@ -0,0 +1,26 @@
+//
+// LPExitRoute.m
+// calabash
+//
+// Created by Trevor Harmon on 11/15/12.
+// Copyright (c) 2012 LessPainful. All rights reserved.
+//
+
+#import "LPExitRoute.h"
+
+@implementation LPExitRoute
+
+- (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path {
+ return [method isEqualToString:@"GET"] || [method isEqualToString:@"POST"];
+}
+
+- (NSDictionary *)JSONResponseForMethod:(NSString *)method
+ URI:(NSString *)path
+ data:(NSDictionary*)data {
+ // Exiting the app causes the HTTP connection to shutdown immediately.
+ // Clients will get an empty response and need to handle the error
+ // condition accordingly.
+ exit(0);
+}
+
+@end
View
3 calabash/Classes/FranklyServer/Routes/LPScreenshotRoute.m
@@ -8,6 +8,8 @@
#import "LPHTTPDataResponse.h"
#import <QuartzCore/QuartzCore.h>
+
+// UIGetScreenImage violates t
@implementation LPScreenshotRoute
- (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path {
@@ -62,6 +64,7 @@ - (NSData*)takeScreenshot
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
+
// NSString* appID = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
// static NSDateFormatter *fm = nil;
View
13 calabash/Classes/FranklyServer/Routes/LPScreenshotRoute2.h
@@ -0,0 +1,13 @@
+//
+// ScreenshotRoute2.h
+// Created by Karl Krukow on 13/08/11.
+// Copyright 2011 LessPainful. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "LPRoute.h"
+
+@interface LPScreenshotRoute2 : NSObject<LPRoute>
+
+- (NSData*)takeScreenshot;
+@end
View
35 calabash/Classes/FranklyServer/Routes/LPScreenshotRoute2.m
@@ -0,0 +1,35 @@
+//
+// ScreenshotRoute2.m
+// Created by Karl Krukow on 13/08/11.
+// Copyright 2011 LessPainful. All rights reserved.
+//
+
+#import "LPScreenshotRoute2.h"
+#import "LPHTTPDataResponse.h"
+#import <QuartzCore/QuartzCore.h>
+CGImageRef UIGetScreenImage(void);
+
+// UIGetScreenImage violates t
+@implementation LPScreenshotRoute2
+
+- (BOOL)supportsMethod:(NSString *)method atPath:(NSString *)path {
+ return [method isEqualToString:@"GET"];
+}
+
+- (NSObject<LPHTTPResponse> *)httpResponseForMethod:(NSString *)method URI:(NSString *)path {
+ LPHTTPDataResponse* drsp = [[LPHTTPDataResponse alloc] initWithData:[self takeScreenshot]];
+ return [drsp autorelease];
+}
+
+
+- (NSData*)takeScreenshot
+{
+
+ CGImageRef screen = UIGetScreenImage();
+ UIImage* image = [UIImage imageWithCGImage:screen];
+ CGImageRelease(screen);
+ return UIImagePNGRepresentation(image);
+}
+
+
+@end
View
11 calabash/Classes/Utils/LPTouchUtils.m
@@ -20,9 +20,7 @@
@implementation LPTouchUtils
-+(CGPoint) translateToScreenCoords:(CGPoint) point {
- UIScreen* s = [UIScreen mainScreen];
-
++(BOOL)is5InchPhone {
UIDevice *device = [UIDevice currentDevice];
BOOL inch5Phone = NO;
if([@"iPhone Simulator" isEqualToString: [device model]])
@@ -35,8 +33,15 @@ +(CGPoint) translateToScreenCoords:(CGPoint) point {
{
inch5Phone = [lp_deviceName() isEqualToString:@"iPhone5,2"];
}
+ return inch5Phone;
+}
+
++(CGPoint) translateToScreenCoords:(CGPoint) point {
+ UIScreen* s = [UIScreen mainScreen];
+ BOOL inch5Phone = [LPTouchUtils is5InchPhone];
+

0 comments on commit 8ebfd43

Please sign in to comment.
Something went wrong with that request. Please try again.