From a2971e18063b55e55079138b328a4dc759996434 Mon Sep 17 00:00:00 2001 From: jock Date: Mon, 25 Nov 2013 11:31:30 +0000 Subject: [PATCH 1/5] Bug-fix: Fall back to orientation via status-bar when orientation via device fails --- src/OrientationCommand.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrientationCommand.m b/src/OrientationCommand.m index 1c948db..f6861e8 100644 --- a/src/OrientationCommand.m +++ b/src/OrientationCommand.m @@ -82,7 +82,7 @@ - (NSString *)getOrientationDescriptionViaDevice{ - (NSString *)handleGet{ NSDictionary *orientationDescription = [self getOrientationRepresentationViaDevice]; if( !orientationDescription ) - orientationDescription = [self getOrientationRepresentationViaDevice]; + orientationDescription = [self getOrientationRepresentationViaStatusBar]; return TO_JSON(orientationDescription); } From ef748a1bd86cc67383a9f049f02f7f7a496c72bb Mon Sep 17 00:00:00 2001 From: seanoshea Date: Thu, 5 Dec 2013 19:15:30 +0000 Subject: [PATCH 2/5] Allowing UIAlertViews be queryable in iOS7. --- gem/lib/frank-cucumber/core_frank_steps.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gem/lib/frank-cucumber/core_frank_steps.rb b/gem/lib/frank-cucumber/core_frank_steps.rb index f452ce9..5fc8cea 100644 --- a/gem/lib/frank-cucumber/core_frank_steps.rb +++ b/gem/lib/frank-cucumber/core_frank_steps.rb @@ -66,7 +66,11 @@ end Then /^I should see an alert view titled "([^\"]*)"$/ do |expected_mark| - values = frankly_map( 'alertView', 'title') + if frankly_os_version.to_f >= 7.0 + values = frankly_map( "view:'_UIModalItemRepresentationView' label", 'text') + else + values = frankly_map( 'alertView', 'title') + end values.should include(expected_mark) end @@ -76,7 +80,11 @@ end Then /^I should not see an alert view$/ do - check_element_does_not_exist( 'alertView' ) + if ENV['LAST_IOS_VERSION'].to_f >= 7.0 + check_element_does_not_exist( '_UIModalItemRepresentationView' ) + else + check_element_does_not_exist( 'alertView' ) + end end Then /^I should see an element of class "([^\"]*)" with name "([^\"]*)" with the following labels: "([^\"]*)"$/ do |className, classLabel, listOfLabels| From 8dc9a385cb65373b8556294e3a5b4a7ccc17b464 Mon Sep 17 00:00:00 2001 From: Sean O' Shea Date: Fri, 6 Dec 2013 09:00:51 +0000 Subject: [PATCH 3/5] Removing debug code in favour of frankly_os_version --- gem/lib/frank-cucumber/core_frank_steps.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gem/lib/frank-cucumber/core_frank_steps.rb b/gem/lib/frank-cucumber/core_frank_steps.rb index 5fc8cea..19dabec 100644 --- a/gem/lib/frank-cucumber/core_frank_steps.rb +++ b/gem/lib/frank-cucumber/core_frank_steps.rb @@ -80,7 +80,7 @@ end Then /^I should not see an alert view$/ do - if ENV['LAST_IOS_VERSION'].to_f >= 7.0 + if frankly_os_version.to_f >= 7.0 check_element_does_not_exist( '_UIModalItemRepresentationView' ) else check_element_does_not_exist( 'alertView' ) From 452df568ed9a74f5801572913dbb2b3d13b0b9ac Mon Sep 17 00:00:00 2001 From: Sean O' Shea Date: Fri, 6 Dec 2013 09:02:44 +0000 Subject: [PATCH 4/5] Updating the pull request for iOS and UIAlertViews --- gem/lib/frank-cucumber/core_frank_steps.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gem/lib/frank-cucumber/core_frank_steps.rb b/gem/lib/frank-cucumber/core_frank_steps.rb index 19dabec..d376ce8 100644 --- a/gem/lib/frank-cucumber/core_frank_steps.rb +++ b/gem/lib/frank-cucumber/core_frank_steps.rb @@ -81,7 +81,7 @@ Then /^I should not see an alert view$/ do if frankly_os_version.to_f >= 7.0 - check_element_does_not_exist( '_UIModalItemRepresentationView' ) + check_element_does_not_exist( '_UIModalItemRepresentationView' ) else check_element_does_not_exist( 'alertView' ) end From a058df9054c65ea8227149d117ac6bd461143ff5 Mon Sep 17 00:00:00 2001 From: "C. Martin Taylor" Date: Tue, 13 Jan 2015 17:56:48 -0600 Subject: [PATCH 5/5] Status Bar Orientation command commit ready to create Pull request. --- Frank.xcodeproj/project.pbxproj | 8 +++++ src/FrankServer.m | 2 ++ src/StatusBarOrientationCommand.h | 16 ++++++++++ src/StatusBarOrientationCommand.m | 50 +++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 src/StatusBarOrientationCommand.h create mode 100644 src/StatusBarOrientationCommand.m diff --git a/Frank.xcodeproj/project.pbxproj b/Frank.xcodeproj/project.pbxproj index e31b649..c9238c6 100644 --- a/Frank.xcodeproj/project.pbxproj +++ b/Frank.xcodeproj/project.pbxproj @@ -85,6 +85,8 @@ 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 */; }; + 53D59F9C1A65E7DB00D1069D /* StatusBarOrientationCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D59F9A1A65E7DB00D1069D /* StatusBarOrientationCommand.h */; }; + 53D59F9D1A65E7DB00D1069D /* StatusBarOrientationCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D59F9B1A65E7DB00D1069D /* StatusBarOrientationCommand.m */; }; 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 */; }; @@ -344,6 +346,8 @@ 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 = ""; }; + 53D59F9A1A65E7DB00D1069D /* StatusBarOrientationCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StatusBarOrientationCommand.h; sourceTree = ""; }; + 53D59F9B1A65E7DB00D1069D /* StatusBarOrientationCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StatusBarOrientationCommand.m; sourceTree = ""; }; 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; }; @@ -722,6 +726,8 @@ 4C1DD76812BADFE100E10B8C /* OrientationCommand.m */, 30AC65A5165C3A4D00DEB0AB /* OSXKeyboardCommand.h */, 30AC65A6165C3A4D00DEB0AB /* OSXKeyboardCommand.m */, + 53D59F9A1A65E7DB00D1069D /* StatusBarOrientationCommand.h */, + 53D59F9B1A65E7DB00D1069D /* StatusBarOrientationCommand.m */, 30C544AF167E4D9E0034F49C /* SuccessCommand.h */, 30C544B0167E4D9E0034F49C /* SuccessCommand.m */, C189EF1C16BB5A8000F8236D /* VersionCommand.h */, @@ -886,6 +892,7 @@ 4C1DD76F12BADFE100E10B8C /* AppCommand.h in Headers */, D67F2AAD13F5E7FA00A0BFF1 /* AccessibilityCheckCommand.h in Headers */, D67F2ABF13F5F55A00A0BFF1 /* FrankLoader.h in Headers */, + 53D59F9C1A65E7DB00D1069D /* StatusBarOrientationCommand.h in Headers */, D67F2B3413F5F82700A0BFF1 /* LoadableCategory.h in Headers */, 0071264614F8956700E738ED /* ViewJSONSerializer.h in Headers */, D6FA01B714283C4F00576AE3 /* FranklyProtocolHelper.h in Headers */, @@ -1258,6 +1265,7 @@ files = ( D6D05CB611C883AA0081C5A5 /* FrankCommandRoute.m in Sources */, D6D05CB811C883AA0081C5A5 /* FrankServer.m in Sources */, + 53D59F9D1A65E7DB00D1069D /* StatusBarOrientationCommand.m in Sources */, D6D05CBA11C883AA0081C5A5 /* MapOperationCommand.m in Sources */, D6D05CBE11C883AA0081C5A5 /* RequestRouter.m in Sources */, D6D05CC011C883AA0081C5A5 /* RoutingHTTPConnection.m in Sources */, diff --git a/src/FrankServer.m b/src/FrankServer.m index 7a50f2d..8f30b8d 100644 --- a/src/FrankServer.m +++ b/src/FrankServer.m @@ -28,6 +28,7 @@ #import "OrientationCommand.h" #import "LocationCommand.h" #import "IOSKeyboardCommand.h" +#import "StatusBarOrientationCommand.h" #else #import "OSXKeyboardCommand.h" #endif @@ -71,6 +72,7 @@ - (id) initWithStaticFrankBundleNamed:(NSString *)bundleName #if TARGET_OS_IPHONE [frankCommandRoute registerCommand:[[[OrientationCommand alloc]init]autorelease] withName:@"orientation"]; + [frankCommandRoute registerCommand:[[[StatusBarOrientationCommand alloc]init]autorelease] withName:@"status_bar_orientation"]; [frankCommandRoute registerCommand:[[[LocationCommand alloc]init]autorelease] withName:@"location"]; [frankCommandRoute registerCommand:[[[IOSKeyboardCommand alloc] init]autorelease] withName:@"type_into_keyboard"]; #else diff --git a/src/StatusBarOrientationCommand.h b/src/StatusBarOrientationCommand.h new file mode 100644 index 0000000..f7a8a97 --- /dev/null +++ b/src/StatusBarOrientationCommand.h @@ -0,0 +1,16 @@ +// +// StatusBarOrientationCommand.h +// Frank +// +// Created by Martin Taylor on 2-May-13. +// Copyright (c) 2013 Texas Instruments, Inc. All rights reserved. +// + +#import +#import "FrankCommandRoute.h" + +@interface StatusBarOrientationCommand : NSObject{ + +} + +@end diff --git a/src/StatusBarOrientationCommand.m b/src/StatusBarOrientationCommand.m new file mode 100644 index 0000000..a7376ef --- /dev/null +++ b/src/StatusBarOrientationCommand.m @@ -0,0 +1,50 @@ +// +// StatusBarOrientationCommand.m +// Frank +// +// Created by Martin Taylor on 2-May-13. +// Copyright (c) 2013 Texas Instruments, Inc. All rights reserved. +// + +#import "StatusBarOrientationCommand.h" + +// Unavailable in iOS7: #import +#import "FranklyProtocolHelper.h" +#import "JSON.h" + +@implementation StatusBarOrientationCommand + +- (NSDictionary *)representOrientation:(NSString *)orientation withDetailedOrientation:(NSString *)detailedOrientation{ + return [NSDictionary dictionaryWithObjectsAndKeys:orientation,@"orientation", detailedOrientation,@"detailed_orientation",nil]; +} + +- (NSDictionary *)getOrientationRepresentationViaStatusBar{ + switch([[UIApplication sharedApplication] statusBarOrientation]){ + case UIInterfaceOrientationLandscapeLeft: + return [self representOrientation:@"landscape" withDetailedOrientation:@"landscape_left"]; + case UIInterfaceOrientationLandscapeRight: + return [self representOrientation:@"landscape" withDetailedOrientation:@"landscape_right"]; + case UIInterfaceOrientationPortrait: + return [self representOrientation:@"portrait" withDetailedOrientation:@"portrait"]; + case UIInterfaceOrientationPortraitUpsideDown: + return [self representOrientation:@"portrait" withDetailedOrientation:@"portrait_upside_down"]; + default: + NSLog(@"Device orientation via status bar is unknown"); + return nil; + } +} + +- (NSString *)handleGet{ + NSDictionary *orientationDescription = [self getOrientationRepresentationViaStatusBar]; + + return TO_JSON(orientationDescription); +} + +- (NSString *)handleCommandWithRequestBody:(NSString *)requestBody { + if( !requestBody || [requestBody isEqualToString:@""] ) + return [self handleGet]; // This is the only option we support + else + return [FranklyProtocolHelper generateErrorResponseWithReason:@"requestBody not supported in StatusBarOrientationCommand" andDetails:requestBody]; // This is an error! +} + +@end