You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/10/01 22:49:39 UTC
git commit: Updated iOS tests for locked orientations
Repository: cordova-plugin-splashscreen
Updated Branches:
refs/heads/master 4d548e67c -> 21f372acc
Updated iOS tests for locked orientations
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/commit/21f372ac
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/tree/21f372ac
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/diff/21f372ac
Branch: refs/heads/master
Commit: 21f372acc98c42c8aaaa2daf3ce84f090c5801eb
Parents: 4d548e6
Author: Shazron Abdullah <sh...@gmail.com>
Authored: Wed Oct 1 13:49:36 2014 -0700
Committer: Shazron Abdullah <sh...@gmail.com>
Committed: Wed Oct 1 13:49:36 2014 -0700
----------------------------------------------------------------------
.../CDVSplashScreenLibTests/ImageNameTest.m | 229 ++++++++++++-------
1 file changed, 144 insertions(+), 85 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/blob/21f372ac/tests/ios/CDVSplashScreenTest/CDVSplashScreenLibTests/ImageNameTest.m
----------------------------------------------------------------------
diff --git a/tests/ios/CDVSplashScreenTest/CDVSplashScreenLibTests/ImageNameTest.m b/tests/ios/CDVSplashScreenTest/CDVSplashScreenLibTests/ImageNameTest.m
index b19cbc5..b01a8d3 100644
--- a/tests/ios/CDVSplashScreenTest/CDVSplashScreenLibTests/ImageNameTest.m
+++ b/tests/ios/CDVSplashScreenTest/CDVSplashScreenLibTests/ImageNameTest.m
@@ -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);
+ XCTAssertTrue([expectedImageName isEqualToString:name], @"%@ - %@ failed (%@)", orientationName, deviceName, name);
+
+}
+
+- (void)testiPadLockedOrientation {
- /// PORTRAIT UPSIDE DOWN
+ 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];
- // 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);
+ LandscapeLeftOnly* delegate3 = [[LandscapeLeftOnly alloc] init];
+ [self lockedOrientationHelper:delegate3 expectedImageName:@"Default-Landscape" orientationName:@"Landscape" device:device];
- // 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);
+ 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
- // 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);
+ AllLandscapeOnly* delegate6 = [[AllLandscapeOnly alloc] init];
+ [self lockedOrientationHelper:delegate6 expectedImageName:@"Default-Landscape" orientationName:@"Landscape" device:device];
+}
+
+- (void)testiPhoneLockedOrientation {
- // 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);
+ 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];
- /// LANDSCAPE LEFT
-
LandscapeLeftOnly* delegate3 = [[LandscapeLeftOnly alloc] init];
+ [self lockedOrientationHelper:delegate3 expectedImageName:@"Default" orientationName:@"Landscape" device:device];
- // 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);
+ LandscapeRightOnly* delegate4 = [[LandscapeRightOnly alloc] init];
+ [self lockedOrientationHelper:delegate4 expectedImageName:@"Default" orientationName:@"Landscape" device:device];
- // 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);
+ // All Portrait
- // 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);
+ AllPortraitOnly* delegate5 = [[AllPortraitOnly alloc] init];
+ [self lockedOrientationHelper:delegate5 expectedImageName:@"Default" orientationName:@"Portrait" device:device];
- // 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);
+ // All Landscape
+
+ AllLandscapeOnly* delegate6 = [[AllLandscapeOnly alloc] init];
+ [self lockedOrientationHelper:delegate6 expectedImageName:@"Default" orientationName:@"Landscape" device:device];
+}
- /// LANDSCAPE RIGHT
+- (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];
- // 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);
+ // All Portrait
- // 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);
+ AllPortraitOnly* delegate5 = [[AllPortraitOnly alloc] init];
+ [self lockedOrientationHelper:delegate5 expectedImageName:@"Default-568h" orientationName:@"Portrait" device:device];
- // 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);
+ // All Landscape
- // 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);
+ 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
- // TODO: Mixed environments
+ 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