Updated iOS tests for locked orientations

This commit is contained in:
Shazron Abdullah 2014-10-01 13:49:36 -07:00
parent 4d548e67c2
commit 21f372acc9

View File

@ -230,128 +230,187 @@ const CDV_iOSDevice CDV_iOSDeviceZero = { 0, 0, 0, 0, 0, 0 };
[self landscapeHelper:UIInterfaceOrientationLandscapeRight delegate:delegate];
}
- (void)testiPadCurrentOrientationNotSupported {
- (void) lockedOrientationHelper:(id<CDVScreenOrientationDelegate>)delegate expectedImageName:(NSString*)expectedImageName orientationName:(NSString*)orientationName device:(CDV_iOSDevice)device{
NSString* name = nil;
CDV_iOSDevice device;
UIInterfaceOrientation currentOrientation;
NSString* deviceName = device.iPad? @"iPad" : device.iPhone6Plus? @"iPhone6Plus": device.iPhone6? @"iPhone6": device.iPhone5? @"iPhone5" : @"iPhone";
/// PORTRAIT
PortraitOnly* delegate = [[PortraitOnly alloc] init];
// LandscapeLeft, iPad - should always return Portrait
device = CDV_iOSDeviceZero; device.iPad = YES;
// LandscapeLeft, should always return expectedImageName
currentOrientation = UIInterfaceOrientationLandscapeLeft;
name = [self.plugin getImageName:currentOrientation delegate:delegate device:device];
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
// LandscapeRight, iPad - should always return Portrait
device = CDV_iOSDeviceZero; device.iPad = YES;
XCTAssertTrue([expectedImageName isEqualToString:name], @"%@ - %@ failed (%@)", orientationName, deviceName, name);
// LandscapeRight - should always return expectedImageName
currentOrientation = UIInterfaceOrientationLandscapeRight;
name = [self.plugin getImageName:currentOrientation delegate:delegate device:device];
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
XCTAssertTrue([expectedImageName isEqualToString:name], @"%@ - %@ failed (%@)", orientationName, deviceName, name);
// Portrait, iPad - should always return Portrait
device = CDV_iOSDeviceZero; device.iPad = YES;
// Portrait - should always return expectedImageName
currentOrientation = UIInterfaceOrientationPortrait;
name = [self.plugin getImageName:currentOrientation delegate:delegate device:device];
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
// PortraitUpsideDown, iPad - should always return Portrait
device = CDV_iOSDeviceZero; device.iPad = YES;
XCTAssertTrue([expectedImageName isEqualToString:name], @"%@ - %@ failed (%@)", orientationName, deviceName, name);
// PortraitUpsideDown - should always return expectedImageName
currentOrientation = UIInterfaceOrientationPortraitUpsideDown;
name = [self.plugin getImageName:currentOrientation delegate:delegate device:device];
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
/// PORTRAIT UPSIDE DOWN
PortraitUpsideDownOnly* delegate2 = [[PortraitUpsideDownOnly alloc] init];
// LandscapeLeft, iPad - should always return Portrait
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationLandscapeLeft;
name = [self.plugin getImageName:currentOrientation delegate:delegate2 device:device];
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
// LandscapeRight, iPad - should always return Portrait
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationLandscapeRight;
name = [self.plugin getImageName:currentOrientation delegate:delegate2 device:device];
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
// Portrait, iPad - should always return Portrait
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationPortrait;
name = [self.plugin getImageName:currentOrientation delegate:delegate2 device:device];
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
// PortraitUpsideDown, iPad - should always return Portrait
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationPortraitUpsideDown;
name = [self.plugin getImageName:currentOrientation delegate:delegate2 device:device];
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
/// LANDSCAPE LEFT
LandscapeLeftOnly* delegate3 = [[LandscapeLeftOnly alloc] init];
// LandscapeLeft, iPad - should always return Landscape
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationLandscapeLeft;
name = [self.plugin getImageName:currentOrientation delegate:delegate3 device:device];
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
// LandscapeRight, iPad - should always return Landscape
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationLandscapeRight;
name = [self.plugin getImageName:currentOrientation delegate:delegate3 device:device];
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
// Portrait, iPad - should always return Landscape
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationPortrait;
name = [self.plugin getImageName:currentOrientation delegate:delegate3 device:device];
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
// PortraitUpsideDown, iPad - should always return Landscape
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationPortraitUpsideDown;
name = [self.plugin getImageName:currentOrientation delegate:delegate3 device:device];
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
/// LANDSCAPE RIGHT
LandscapeRightOnly* delegate4 = [[LandscapeRightOnly alloc] init];
// LandscapeLeft, iPad - should always return Landscape
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationLandscapeLeft;
name = [self.plugin getImageName:currentOrientation delegate:delegate4 device:device];
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
// LandscapeRight, iPad - should always return Landscape
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationLandscapeRight;
name = [self.plugin getImageName:currentOrientation delegate:delegate4 device:device];
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
// Portrait, iPad - should always return Landscape
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationPortrait;
name = [self.plugin getImageName:currentOrientation delegate:delegate4 device:device];
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
// PortraitUpsideDown, iPad - should always return Landscape
device = CDV_iOSDeviceZero; device.iPad = YES;
currentOrientation = UIInterfaceOrientationPortraitUpsideDown;
name = [self.plugin getImageName:currentOrientation delegate:delegate4 device:device];
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
// TODO: Mixed environments
XCTAssertTrue([expectedImageName isEqualToString:name], @"%@ - %@ failed (%@)", orientationName, deviceName, name);
}
- (void)testiPadLockedOrientation {
CDV_iOSDevice device = CDV_iOSDeviceZero;
device.iPad = YES;
// One orientation
PortraitOnly* delegate = [[PortraitOnly alloc] init];
[self lockedOrientationHelper:delegate expectedImageName:@"Default-Portrait" orientationName:@"Portrait" device:device];
PortraitUpsideDownOnly* delegate2 = [[PortraitUpsideDownOnly alloc] init];
[self lockedOrientationHelper:delegate2 expectedImageName:@"Default-Portrait" orientationName:@"Portrait" device:device];
LandscapeLeftOnly* delegate3 = [[LandscapeLeftOnly alloc] init];
[self lockedOrientationHelper:delegate3 expectedImageName:@"Default-Landscape" orientationName:@"Landscape" device:device];
LandscapeRightOnly* delegate4 = [[LandscapeRightOnly alloc] init];
[self lockedOrientationHelper:delegate4 expectedImageName:@"Default-Landscape" orientationName:@"Landscape" device:device];
// All Portrait
AllPortraitOnly* delegate5 = [[AllPortraitOnly alloc] init];
[self lockedOrientationHelper:delegate5 expectedImageName:@"Default-Portrait" orientationName:@"Portrait" device:device];
// All Landscape
AllLandscapeOnly* delegate6 = [[AllLandscapeOnly alloc] init];
[self lockedOrientationHelper:delegate6 expectedImageName:@"Default-Landscape" orientationName:@"Landscape" device:device];
}
- (void)testiPhoneLockedOrientation {
CDV_iOSDevice device = CDV_iOSDeviceZero;
device.iPhone = YES;
// One orientation
PortraitOnly* delegate = [[PortraitOnly alloc] init];
[self lockedOrientationHelper:delegate expectedImageName:@"Default" orientationName:@"Portrait" device:device];
PortraitUpsideDownOnly* delegate2 = [[PortraitUpsideDownOnly alloc] init];
[self lockedOrientationHelper:delegate2 expectedImageName:@"Default" orientationName:@"Portrait" device:device];
LandscapeLeftOnly* delegate3 = [[LandscapeLeftOnly alloc] init];
[self lockedOrientationHelper:delegate3 expectedImageName:@"Default" orientationName:@"Landscape" device:device];
LandscapeRightOnly* delegate4 = [[LandscapeRightOnly alloc] init];
[self lockedOrientationHelper:delegate4 expectedImageName:@"Default" orientationName:@"Landscape" device:device];
// All Portrait
AllPortraitOnly* delegate5 = [[AllPortraitOnly alloc] init];
[self lockedOrientationHelper:delegate5 expectedImageName:@"Default" orientationName:@"Portrait" device:device];
// All Landscape
AllLandscapeOnly* delegate6 = [[AllLandscapeOnly alloc] init];
[self lockedOrientationHelper:delegate6 expectedImageName:@"Default" orientationName:@"Landscape" device:device];
}
- (void)testiPhone5LockedOrientation {
CDV_iOSDevice device = CDV_iOSDeviceZero;
device.iPhone = YES;
device.iPhone5 = YES;
// One orientation
PortraitOnly* delegate = [[PortraitOnly alloc] init];
[self lockedOrientationHelper:delegate expectedImageName:@"Default-568h" orientationName:@"Portrait" device:device];
PortraitUpsideDownOnly* delegate2 = [[PortraitUpsideDownOnly alloc] init];
[self lockedOrientationHelper:delegate2 expectedImageName:@"Default-568h" orientationName:@"Portrait" device:device];
LandscapeLeftOnly* delegate3 = [[LandscapeLeftOnly alloc] init];
[self lockedOrientationHelper:delegate3 expectedImageName:@"Default-568h" orientationName:@"Landscape" device:device];
LandscapeRightOnly* delegate4 = [[LandscapeRightOnly alloc] init];
[self lockedOrientationHelper:delegate4 expectedImageName:@"Default-568h" orientationName:@"Landscape" device:device];
// All Portrait
AllPortraitOnly* delegate5 = [[AllPortraitOnly alloc] init];
[self lockedOrientationHelper:delegate5 expectedImageName:@"Default-568h" orientationName:@"Portrait" device:device];
// All Landscape
AllLandscapeOnly* delegate6 = [[AllLandscapeOnly alloc] init];
[self lockedOrientationHelper:delegate6 expectedImageName:@"Default-568h" orientationName:@"Landscape" device:device];
}
- (void)testiPhone6LockedOrientation {
CDV_iOSDevice device = CDV_iOSDeviceZero;
device.iPhone = YES;
device.iPhone6 = YES;
// One orientation
PortraitOnly* delegate = [[PortraitOnly alloc] init];
[self lockedOrientationHelper:delegate expectedImageName:@"Default-667h" orientationName:@"Portrait" device:device];
PortraitUpsideDownOnly* delegate2 = [[PortraitUpsideDownOnly alloc] init];
[self lockedOrientationHelper:delegate2 expectedImageName:@"Default-667h" orientationName:@"Portrait" device:device];
LandscapeLeftOnly* delegate3 = [[LandscapeLeftOnly alloc] init];
[self lockedOrientationHelper:delegate3 expectedImageName:@"Default-667h" orientationName:@"Landscape" device:device];
LandscapeRightOnly* delegate4 = [[LandscapeRightOnly alloc] init];
[self lockedOrientationHelper:delegate4 expectedImageName:@"Default-667h" orientationName:@"Landscape" device:device];
// All Portrait
AllPortraitOnly* delegate5 = [[AllPortraitOnly alloc] init];
[self lockedOrientationHelper:delegate5 expectedImageName:@"Default-667h" orientationName:@"Portrait" device:device];
// All Landscape
AllLandscapeOnly* delegate6 = [[AllLandscapeOnly alloc] init];
[self lockedOrientationHelper:delegate6 expectedImageName:@"Default-667h" orientationName:@"Landscape" device:device];
}
- (void)testiPhone6PlusLockedOrientation {
CDV_iOSDevice device = CDV_iOSDeviceZero;
device.iPhone = YES;
device.iPhone6Plus = YES;
// One orientation
PortraitOnly* delegate = [[PortraitOnly alloc] init];
[self lockedOrientationHelper:delegate expectedImageName:@"Default-736h" orientationName:@"Portrait" device:device];
PortraitUpsideDownOnly* delegate2 = [[PortraitUpsideDownOnly alloc] init];
[self lockedOrientationHelper:delegate2 expectedImageName:@"Default-736h" orientationName:@"Portrait" device:device];
LandscapeLeftOnly* delegate3 = [[LandscapeLeftOnly alloc] init];
[self lockedOrientationHelper:delegate3 expectedImageName:@"Default-Landscape-736h" orientationName:@"Landscape" device:device];
LandscapeRightOnly* delegate4 = [[LandscapeRightOnly alloc] init];
[self lockedOrientationHelper:delegate4 expectedImageName:@"Default-Landscape-736h" orientationName:@"Landscape" device:device];
// All Portrait
AllPortraitOnly* delegate5 = [[AllPortraitOnly alloc] init];
[self lockedOrientationHelper:delegate5 expectedImageName:@"Default-736h" orientationName:@"Portrait" device:device];
// All Landscape
AllLandscapeOnly* delegate6 = [[AllLandscapeOnly alloc] init];
[self lockedOrientationHelper:delegate6 expectedImageName:@"Default-Landscape-736h" orientationName:@"Landscape" device:device];
}
@end