mirror of
https://github.com/apache/cordova-plugin-splashscreen.git
synced 2026-04-14 00:01:34 +08:00
CB-7663 - iOS unit tests for splash screen
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <Cordova/CDVScreenOrientationDelegate.h>
|
||||
#import "CDVSplashScreen.h"
|
||||
#import "ImageNameTestDelegates.h"
|
||||
|
||||
@interface ImageNameTest : XCTestCase
|
||||
|
||||
@property (nonatomic, strong) CDVSplashScreen* plugin;
|
||||
|
||||
@end
|
||||
|
||||
@interface CDVSplashScreen ()
|
||||
|
||||
// expose private interface
|
||||
- (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id<CDVScreenOrientationDelegate>)orientationDelegate isIPad:(BOOL)isIPad isIPhone5:(BOOL)isIPhone5;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ImageNameTest
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
|
||||
self.plugin = [[CDVSplashScreen alloc] init];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void) portraitHelper:(UIInterfaceOrientation)initialOrientation delegate:(id<CDVScreenOrientationDelegate>)delegate
|
||||
{
|
||||
NSString* name = nil;
|
||||
|
||||
// Portrait, non-iPad, non-iPhone5
|
||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:NO isIPhone5:NO];
|
||||
XCTAssertTrue([@"Default" isEqualToString:name], @"Portrait - 3.5\" iPhone failed (%@)", name);
|
||||
|
||||
// Portrait, iPad, non-iPhone5
|
||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:YES isIPhone5:NO];
|
||||
XCTAssertTrue([@"Default-Portrait" isEqualToString:name], @"Portrait - iPad failed (%@)", name);
|
||||
|
||||
// Portrait, non-iPad, iPhone5
|
||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:NO isIPhone5:YES];
|
||||
XCTAssertTrue([@"Default-568h" isEqualToString:name], @"Portrait - iPhone 5 failed (%@)", name);
|
||||
}
|
||||
|
||||
- (void) landscapeHelper:(UIInterfaceOrientation)initialOrientation delegate:(id<CDVScreenOrientationDelegate>)delegate
|
||||
{
|
||||
NSString* name = nil;
|
||||
|
||||
// Landscape, non-iPad, non-iPhone5 (does NOT support landscape)
|
||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:NO isIPhone5:NO];
|
||||
XCTAssertTrue([@"Default" isEqualToString:name], @"Landscape - 3.5\" iPhone failed (%@)", name );
|
||||
|
||||
// Landscape, iPad, non-iPhone5 (supports landscape)
|
||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:YES isIPhone5:NO];
|
||||
XCTAssertTrue([@"Default-Landscape" isEqualToString:name], @"Landscape - iPad failed (%@)", name);
|
||||
|
||||
// Landscape, non-iPad, iPhone5 (does NOT support landscape)
|
||||
name = [self.plugin getImageName:initialOrientation delegate:delegate isIPad:NO isIPhone5:YES];
|
||||
XCTAssertTrue([@"Default-568h" isEqualToString:name], @"Landscape - iPhone5 failed (%@)", name);
|
||||
}
|
||||
|
||||
- (void)testPortraitOnly {
|
||||
|
||||
PortraitOnly* delegate = [[PortraitOnly alloc] init];
|
||||
[self portraitHelper:UIInterfaceOrientationPortrait delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testPortraitUpsideDownOnly {
|
||||
|
||||
PortraitUpsideDownOnly* delegate = [[PortraitUpsideDownOnly alloc] init];
|
||||
[self portraitHelper:UIInterfaceOrientationPortraitUpsideDown delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testAllPortraitOnly {
|
||||
|
||||
AllPortraitOnly* delegate = [[AllPortraitOnly alloc] init];
|
||||
[self portraitHelper:UIInterfaceOrientationPortrait delegate:delegate];
|
||||
[self portraitHelper:UIInterfaceOrientationPortraitUpsideDown delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testLandscapeLeftOnly {
|
||||
|
||||
LandscapeLeftOnly* delegate = [[LandscapeLeftOnly alloc] init];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeLeft delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testLandscapeRightOnly {
|
||||
|
||||
LandscapeRightOnly* delegate = [[LandscapeRightOnly alloc] init];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeRight delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testAllLandscapeOnly {
|
||||
|
||||
AllLandscapeOnly* delegate = [[AllLandscapeOnly alloc] init];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeLeft delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeRight delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testAllOrientations {
|
||||
|
||||
AllOrientations* delegate = [[AllOrientations alloc] init];
|
||||
// try all orientations
|
||||
[self portraitHelper:UIInterfaceOrientationPortrait delegate:delegate];
|
||||
[self portraitHelper:UIInterfaceOrientationPortraitUpsideDown delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeLeft delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeRight delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testPortraitAndLandscapeLeft {
|
||||
|
||||
PortraitAndLandscapeLeftOnly* delegate = [[PortraitAndLandscapeLeftOnly alloc] init];
|
||||
// try all orientations
|
||||
[self portraitHelper:UIInterfaceOrientationPortrait delegate:delegate];
|
||||
[self portraitHelper:UIInterfaceOrientationPortraitUpsideDown delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeLeft delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeRight delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testPortraitAndLandscapeRight {
|
||||
|
||||
PortraitAndLandscapeRightOnly* delegate = [[PortraitAndLandscapeRightOnly alloc] init];
|
||||
// try all orientations
|
||||
[self portraitHelper:UIInterfaceOrientationPortrait delegate:delegate];
|
||||
[self portraitHelper:UIInterfaceOrientationPortraitUpsideDown delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeLeft delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeRight delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testPortraitUpsideDownAndLandscapeLeft {
|
||||
|
||||
PortraitUpsideDownAndLandscapeLeftOnly* delegate = [[PortraitUpsideDownAndLandscapeLeftOnly alloc] init];
|
||||
// try all orientations
|
||||
[self portraitHelper:UIInterfaceOrientationPortrait delegate:delegate];
|
||||
[self portraitHelper:UIInterfaceOrientationPortraitUpsideDown delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeLeft delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeRight delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)testPortraitUpsideDownAndLandscapeRight {
|
||||
|
||||
PortraitUpsideDownAndLandscapeRightOnly* delegate = [[PortraitUpsideDownAndLandscapeRightOnly alloc] init];
|
||||
// try all orientations
|
||||
[self portraitHelper:UIInterfaceOrientationPortrait delegate:delegate];
|
||||
[self portraitHelper:UIInterfaceOrientationPortraitUpsideDown delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeLeft delegate:delegate];
|
||||
[self landscapeHelper:UIInterfaceOrientationLandscapeRight delegate:delegate];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Cordova/CDVScreenOrientationDelegate.h>
|
||||
|
||||
@interface PortraitOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
@interface PortraitUpsideDownOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
@interface AllPortraitOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
|
||||
@interface LandscapeLeftOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
@interface LandscapeRightOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
@interface AllLandscapeOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
|
||||
@interface AllOrientations : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
@interface PortraitAndLandscapeLeftOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
@interface PortraitAndLandscapeRightOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
@interface PortraitUpsideDownAndLandscapeLeftOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
@interface PortraitUpsideDownAndLandscapeRightOnly : NSObject <CDVScreenOrientationDelegate>
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ImageNameTestDelegates.h"
|
||||
|
||||
@implementation PortraitOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskPortrait;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PortraitUpsideDownOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskPortraitUpsideDown;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation AllPortraitOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation LandscapeLeftOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskLandscapeLeft;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation LandscapeRightOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskLandscapeRight;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation AllLandscapeOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation AllOrientations
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskAll;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PortraitAndLandscapeLeftOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PortraitAndLandscapeRightOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeRight;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PortraitUpsideDownAndLandscapeLeftOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskPortraitUpsideDown | UIInterfaceOrientationMaskLandscapeLeft;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PortraitUpsideDownAndLandscapeRightOnly
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations {
|
||||
return UIInterfaceOrientationMaskPortraitUpsideDown | UIInterfaceOrientationMaskLandscapeRight;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return [self supportedInterfaceOrientations] & (1 << interfaceOrientation) ;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.apache.cordova.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user