Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status bar orientation #39

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions Frank.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -344,6 +346,8 @@
4C1DD76912BADFE100E10B8C /* OrientationCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrientationCommand.h; sourceTree = "<group>"; };
4C1DD76A12BADFE100E10B8C /* AppCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppCommand.m; sourceTree = "<group>"; };
4C1DD76B12BADFE100E10B8C /* AppCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppCommand.h; sourceTree = "<group>"; };
53D59F9A1A65E7DB00D1069D /* StatusBarOrientationCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StatusBarOrientationCommand.h; sourceTree = "<group>"; };
53D59F9B1A65E7DB00D1069D /* StatusBarOrientationCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StatusBarOrientationCommand.m; sourceTree = "<group>"; };
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; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
12 changes: 10 additions & 2 deletions gem/lib/frank-cucumber/core_frank_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -76,7 +80,11 @@
end

Then /^I should not see an alert view$/ do
check_element_does_not_exist( 'alertView' )
if frankly_os_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|
Expand Down
2 changes: 2 additions & 0 deletions src/FrankServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import "OrientationCommand.h"
#import "LocationCommand.h"
#import "IOSKeyboardCommand.h"
#import "StatusBarOrientationCommand.h"
#else
#import "OSXKeyboardCommand.h"
#endif
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/OrientationCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ - (NSString *)getOrientationDescriptionViaDevice{
- (NSString *)handleGet{
NSDictionary *orientationDescription = [self getOrientationRepresentationViaDevice];
if( !orientationDescription )
orientationDescription = [self getOrientationRepresentationViaDevice];
orientationDescription = [self getOrientationRepresentationViaStatusBar];

return TO_JSON(orientationDescription);
}
Expand Down
16 changes: 16 additions & 0 deletions src/StatusBarOrientationCommand.h
Original file line number Diff line number Diff line change
@@ -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 <Foundation/Foundation.h>
#import "FrankCommandRoute.h"

@interface StatusBarOrientationCommand : NSObject<FrankCommand>{

}

@end
50 changes: 50 additions & 0 deletions src/StatusBarOrientationCommand.m
Original file line number Diff line number Diff line change
@@ -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 <PublicAutomation/UIAutomationBridge.h>
#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