Added failing iPhone 6/6 Plus tests.
This commit is contained in:
parent
95f407ea0d
commit
0ffe1c2d46
@ -20,6 +20,16 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <Cordova/CDVPlugin.h>
|
#import <Cordova/CDVPlugin.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BOOL iPhone;
|
||||||
|
BOOL iPad;
|
||||||
|
BOOL iPhone5;
|
||||||
|
BOOL iPhone6;
|
||||||
|
BOOL iPhone6Plus;
|
||||||
|
BOOL retina;
|
||||||
|
|
||||||
|
} CDV_iOSDevice;
|
||||||
|
|
||||||
@interface CDVSplashScreen : CDVPlugin {
|
@interface CDVSplashScreen : CDVPlugin {
|
||||||
UIActivityIndicatorView* _activityView;
|
UIActivityIndicatorView* _activityView;
|
||||||
UIImageView* _imageView;
|
UIImageView* _imageView;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#define kSplashScreenDurationDefault 0.25f
|
#define kSplashScreenDurationDefault 0.25f
|
||||||
|
|
||||||
|
|
||||||
@implementation CDVSplashScreen
|
@implementation CDVSplashScreen
|
||||||
|
|
||||||
- (void)pluginInitialize
|
- (void)pluginInitialize
|
||||||
@ -117,7 +118,27 @@
|
|||||||
[self.viewController.view removeObserver:self forKeyPath:@"bounds"];
|
[self.viewController.view removeObserver:self forKeyPath:@"bounds"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id<CDVScreenOrientationDelegate>)orientationDelegate isIPad:(BOOL)isIPad isIPhone5:(BOOL)isIPhone5
|
- (CDV_iOSDevice) getCurrentDevice
|
||||||
|
{
|
||||||
|
CDV_iOSDevice device;
|
||||||
|
|
||||||
|
UIScreen* mainScreen = [UIScreen mainScreen];
|
||||||
|
CGFloat mainScreenHeight = mainScreen.bounds.size.height;
|
||||||
|
|
||||||
|
device.iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
|
||||||
|
device.iPhone = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
|
||||||
|
device.retina = ([mainScreen scale] == 2.0);
|
||||||
|
device.iPhone5 = (device.iPhone && mainScreenHeight == 568.0);
|
||||||
|
// note these below is not a true device detect, for example if you are on an
|
||||||
|
// iPhone 6/6+ but the app is scaled it will prob set iPhone5 as true, but
|
||||||
|
// this is appropriate for detecting the runtime screen environment
|
||||||
|
device.iPhone6 = (device.iPhone && mainScreenHeight == 667.0);
|
||||||
|
device.iPhone6Plus = (device.iPhone && mainScreenHeight == 736.0);
|
||||||
|
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id<CDVScreenOrientationDelegate>)orientationDelegate device:(CDV_iOSDevice)device
|
||||||
{
|
{
|
||||||
// Use UILaunchImageFile if specified in plist. Otherwise, use Default.
|
// Use UILaunchImageFile if specified in plist. Otherwise, use Default.
|
||||||
NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
|
NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
|
||||||
@ -135,9 +156,9 @@
|
|||||||
imageName = @"Default";
|
imageName = @"Default";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isIPhone5) {
|
if (device.iPhone5) {
|
||||||
imageName = [imageName stringByAppendingString:@"-568h"];
|
imageName = [imageName stringByAppendingString:@"-568h"];
|
||||||
} else if (isIPad) {
|
} else if (device.iPad) {
|
||||||
if (isOrientationLocked) {
|
if (isOrientationLocked) {
|
||||||
imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"-Portrait")];
|
imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"-Portrait")];
|
||||||
} else {
|
} else {
|
||||||
@ -162,7 +183,7 @@
|
|||||||
// Sets the view's frame and image.
|
// Sets the view's frame and image.
|
||||||
- (void)updateImage
|
- (void)updateImage
|
||||||
{
|
{
|
||||||
NSString* imageName = [self getImageName:self.viewController.interfaceOrientation delegate:(id<CDVScreenOrientationDelegate>)self.viewController isIPad:CDV_IsIPad() isIPhone5:CDV_IsIPhone5()];
|
NSString* imageName = [self getImageName:self.viewController.interfaceOrientation delegate:(id<CDVScreenOrientationDelegate>)self.viewController device:[self getCurrentDevice]];
|
||||||
|
|
||||||
if (![imageName isEqualToString:_curImageName]) {
|
if (![imageName isEqualToString:_curImageName]) {
|
||||||
UIImage* img = [UIImage imageNamed:imageName];
|
UIImage* img = [UIImage imageNamed:imageName];
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#import "CDVSplashScreen.h"
|
#import "CDVSplashScreen.h"
|
||||||
#import "ImageNameTestDelegates.h"
|
#import "ImageNameTestDelegates.h"
|
||||||
|
|
||||||
|
const CDV_iOSDevice CDV_iOSDeviceZero = { 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
@interface ImageNameTest : XCTestCase
|
@interface ImageNameTest : XCTestCase
|
||||||
|
|
||||||
@property (nonatomic, strong) CDVSplashScreen* plugin;
|
@property (nonatomic, strong) CDVSplashScreen* plugin;
|
||||||
@ -32,7 +34,7 @@
|
|||||||
@interface CDVSplashScreen ()
|
@interface CDVSplashScreen ()
|
||||||
|
|
||||||
// expose private interface
|
// expose private interface
|
||||||
- (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id<CDVScreenOrientationDelegate>)orientationDelegate isIPad:(BOOL)isIPad isIPhone5:(BOOL)isIPhone5;
|
- (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id<CDVScreenOrientationDelegate>)orientationDelegate device:(CDV_iOSDevice)device;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -53,35 +55,64 @@
|
|||||||
- (void) portraitHelper:(UIInterfaceOrientation)initialOrientation delegate:(id<CDVScreenOrientationDelegate>)delegate
|
- (void) portraitHelper:(UIInterfaceOrientation)initialOrientation delegate:(id<CDVScreenOrientationDelegate>)delegate
|
||||||
{
|
{
|
||||||
NSString* name = nil;
|
NSString* name = nil;
|
||||||
|
CDV_iOSDevice device;
|
||||||
|
|
||||||
// Portrait, non-iPad, non-iPhone5
|
// Portrait, non-iPad, non-iPhone5
|
||||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:NO isIPhone5:NO];
|
device = CDV_iOSDeviceZero; device.iPad = NO; device.iPhone5 = NO;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
XCTAssertTrue([@"Default" isEqualToString:name], @"Portrait - 3.5\" iPhone failed (%@)", name);
|
XCTAssertTrue([@"Default" isEqualToString:name], @"Portrait - 3.5\" iPhone failed (%@)", name);
|
||||||
|
|
||||||
// Portrait, iPad, non-iPhone5
|
// Portrait, iPad, non-iPhone5
|
||||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:YES isIPhone5:NO];
|
device = CDV_iOSDeviceZero; device.iPad = YES; device.iPhone5 = NO;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
|
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
|
||||||
|
|
||||||
// Portrait, non-iPad, iPhone5
|
// Portrait, non-iPad, iPhone5
|
||||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:NO isIPhone5:YES];
|
device = CDV_iOSDeviceZero; device.iPad = NO; device.iPhone5 = YES;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
XCTAssertTrue([@"Default-568h" isEqualToString:name], @"Portrait - iPhone 5 failed (%@)", name);
|
XCTAssertTrue([@"Default-568h" isEqualToString:name], @"Portrait - iPhone 5 failed (%@)", name);
|
||||||
|
|
||||||
|
// Portrait, non-iPad, iPhone6
|
||||||
|
device = CDV_iOSDeviceZero; device.iPad = NO; device.iPhone6 = YES;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
|
XCTAssertTrue([@"Default-667h" isEqualToString:name], @"Portrait - iPhone 6 failed (%@)", name);
|
||||||
|
|
||||||
|
// Portrait, non-iPad, iPhone6Plus
|
||||||
|
device = CDV_iOSDeviceZero; device.iPad = NO; device.iPhone6Plus = YES;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
|
XCTAssertTrue([@"Default-736h" isEqualToString:name], @"Portrait - iPhone 6Plus failed (%@)", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) landscapeHelper:(UIInterfaceOrientation)initialOrientation delegate:(id<CDVScreenOrientationDelegate>)delegate
|
- (void) landscapeHelper:(UIInterfaceOrientation)initialOrientation delegate:(id<CDVScreenOrientationDelegate>)delegate
|
||||||
{
|
{
|
||||||
NSString* name = nil;
|
NSString* name = nil;
|
||||||
|
CDV_iOSDevice device;
|
||||||
|
|
||||||
// Landscape, non-iPad, non-iPhone5 (does NOT support landscape)
|
// Landscape, non-iPad, non-iPhone5 (does NOT support landscape)
|
||||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:NO isIPhone5:NO];
|
device = CDV_iOSDeviceZero; device.iPad = NO; device.iPhone5 = NO;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
XCTAssertTrue([@"Default" isEqualToString:name], @"Landscape - 3.5\" iPhone failed (%@)", name );
|
XCTAssertTrue([@"Default" isEqualToString:name], @"Landscape - 3.5\" iPhone failed (%@)", name );
|
||||||
|
|
||||||
// Landscape, iPad, non-iPhone5 (supports landscape)
|
// Landscape, iPad, non-iPhone5 (supports landscape)
|
||||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:YES isIPhone5:NO];
|
device = CDV_iOSDeviceZero; device.iPad = YES; device.iPhone5 = NO;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
|
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
|
||||||
|
|
||||||
// Landscape, non-iPad, iPhone5 (does NOT support landscape)
|
// Landscape, non-iPad, iPhone5 (does NOT support landscape)
|
||||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:NO isIPhone5:YES];
|
device = CDV_iOSDeviceZero; device.iPad = NO; device.iPhone5 = YES;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
XCTAssertTrue([@"Default-568h" isEqualToString:name], @"Landscape - iPhone5 failed (%@)", name);
|
XCTAssertTrue([@"Default-568h" isEqualToString:name], @"Landscape - iPhone5 failed (%@)", name);
|
||||||
|
|
||||||
|
// Landscape, non-iPad, iPhone6 (does NOT support landscape)
|
||||||
|
device = CDV_iOSDeviceZero; device.iPad = NO; device.iPhone6 = YES;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
|
XCTAssertTrue([@"Default-667h" isEqualToString:name], @"Landscape - iPhone6 failed (%@)", name);
|
||||||
|
|
||||||
|
// Landscape, non-iPad, iPhone6Plus (does support landscape)
|
||||||
|
device = CDV_iOSDeviceZero; device.iPad = NO; device.iPhone6Plus = YES;
|
||||||
|
name = [self.plugin getImageName:initialOrientation delegate:delegate device:device];
|
||||||
|
XCTAssertTrue([@"Default-Landscape-736h" isEqualToString:name], @"Landscape - iPhone6Plus failed (%@)", name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testPortraitOnly {
|
- (void)testPortraitOnly {
|
||||||
|
@ -57,8 +57,8 @@
|
|||||||
7E9F519519DA102000DA31AC /* libCDVSplashScreenLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCDVSplashScreenLib.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
7E9F519519DA102000DA31AC /* libCDVSplashScreenLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCDVSplashScreenLib.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
7E9F519F19DA102000DA31AC /* CDVSplashScreenLibTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CDVSplashScreenLibTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
7E9F519F19DA102000DA31AC /* CDVSplashScreenLibTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CDVSplashScreenLibTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
7E9F51A219DA102000DA31AC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
7E9F51A219DA102000DA31AC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
7E9F51A919DA10AE00DA31AC /* CDVSplashScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSplashScreen.m; path = ../../../../src/ios/CDVSplashScreen.m; sourceTree = "<group>"; };
|
7E9F51A919DA10AE00DA31AC /* CDVSplashScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSplashScreen.m; path = ../../../src/ios/CDVSplashScreen.m; sourceTree = SOURCE_ROOT; };
|
||||||
7E9F51AA19DA10AE00DA31AC /* CDVSplashScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSplashScreen.h; path = ../../../../src/ios/CDVSplashScreen.h; sourceTree = "<group>"; };
|
7E9F51AA19DA10AE00DA31AC /* CDVSplashScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSplashScreen.h; path = ../../../src/ios/CDVSplashScreen.h; sourceTree = SOURCE_ROOT; };
|
||||||
7E9F51B019DA114400DA31AC /* ImageNameTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageNameTest.m; sourceTree = "<group>"; };
|
7E9F51B019DA114400DA31AC /* ImageNameTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageNameTest.m; sourceTree = "<group>"; };
|
||||||
7E9F51B219DA116500DA31AC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
7E9F51B219DA116500DA31AC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
7E9F51B419DA127E00DA31AC /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
|
7E9F51B419DA127E00DA31AC /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
@ -124,7 +124,7 @@
|
|||||||
7E9F51AA19DA10AE00DA31AC /* CDVSplashScreen.h */,
|
7E9F51AA19DA10AE00DA31AC /* CDVSplashScreen.h */,
|
||||||
);
|
);
|
||||||
path = CDVSplashScreenLib;
|
path = CDVSplashScreenLib;
|
||||||
sourceTree = "<group>";
|
sourceTree = SOURCE_ROOT;
|
||||||
};
|
};
|
||||||
7E9F51A019DA102000DA31AC /* CDVSplashScreenLibTests */ = {
|
7E9F51A019DA102000DA31AC /* CDVSplashScreenLibTests */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user