add application tests
This commit is contained in:
parent
6d661843d5
commit
7d417bb52b
|
@ -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>$(PRODUCT_BUNDLE_IDENTIFIER)</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>
|
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// STPPaymentCardTextFieldUITests.m
|
||||
// Stripe iOS Example (Simple)
|
||||
//
|
||||
// Created by Ben Guo on 1/12/16.
|
||||
// Copyright © 2016 Stripe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <Stripe/Stripe.h>
|
||||
|
||||
@interface STPPaymentCardTextField (Testing)
|
||||
@property(nonatomic, readwrite, weak)UIImageView *brandImageView;
|
||||
@property(nonatomic, readwrite, weak)UITextField *numberField;
|
||||
@property(nonatomic, readwrite, weak)UITextField *expirationField;
|
||||
@property(nonatomic, readwrite, weak)UITextField *cvcField;
|
||||
@property(nonatomic, readwrite, weak)UITextField *selectedField;
|
||||
@property(nonatomic, assign)BOOL numberFieldShrunk;
|
||||
+ (UIImage *)cvcImageForCardBrand:(STPCardBrand)cardBrand;
|
||||
+ (UIImage *)brandImageForCardBrand:(STPCardBrand)cardBrand;
|
||||
@end
|
||||
|
||||
@interface STPPaymentCardTextFieldUITests : XCTestCase
|
||||
@property (nonatomic, strong) STPPaymentCardTextField *sut;
|
||||
@property (nonatomic, strong) UIViewController *viewController;
|
||||
@end
|
||||
|
||||
@implementation STPPaymentCardTextFieldUITests
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
self.viewController = [UIViewController new];
|
||||
self.sut = [STPPaymentCardTextField new];
|
||||
[self.viewController.view addSubview:self.sut];
|
||||
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
|
||||
window.rootViewController = self.viewController;
|
||||
}
|
||||
|
||||
- (void)testSetCard_allFields_whileEditingNumber {
|
||||
XCTAssertTrue([self.sut.numberField becomeFirstResponder]);
|
||||
STPCardParams *card = [STPCardParams new];
|
||||
NSString *number = @"4242424242424242";
|
||||
NSString *cvc = @"123";
|
||||
card.number = number;
|
||||
card.expMonth = 10;
|
||||
card.expYear = 99;
|
||||
card.cvc = cvc;
|
||||
[self.sut setCard:card];
|
||||
NSData *imgData = UIImagePNGRepresentation(self.sut.brandImageView.image);
|
||||
NSData *expectedImgData = UIImagePNGRepresentation([STPPaymentCardTextField cvcImageForCardBrand:STPCardBrandVisa]);
|
||||
|
||||
XCTAssertTrue(self.sut.numberFieldShrunk);
|
||||
XCTAssertTrue([expectedImgData isEqualToData:imgData]);
|
||||
XCTAssertEqualObjects(self.sut.numberField.text, number);
|
||||
XCTAssertEqualObjects(self.sut.expirationField.text, @"10/99");
|
||||
XCTAssertEqualObjects(self.sut.cvcField.text, cvc);
|
||||
XCTAssertEqualObjects(self.sut.selectedField, self.sut.cvcField);
|
||||
XCTAssertTrue(self.sut.isValid);
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,4 @@
|
|||
//
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
|
@ -13,8 +13,19 @@
|
|||
042CA4221A685E8D00D778E7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 042CA41C1A685E8D00D778E7 /* ViewController.swift */; };
|
||||
04D0761D1A69E66F00094431 /* Stripe.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04D076191A69C14700094431 /* Stripe.framework */; };
|
||||
04D0761E1A69E66F00094431 /* Stripe.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 04D076191A69C14700094431 /* Stripe.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
C11745DF1C456D6D0029936F /* STPPaymentCardTextFieldUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = C11745DE1C456D6D0029936F /* STPPaymentCardTextFieldUITests.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
C11745D81C456C730029936F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 04823F701A6849200098400B /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 04823F771A6849200098400B;
|
||||
remoteInfo = "Stripe iOS Example (Simple)";
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
04D0761F1A69E66F00094431 /* Embed Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
|
@ -38,6 +49,10 @@
|
|||
04823F781A6849200098400B /* Stripe iOS Example (Simple).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Stripe iOS Example (Simple).app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
04D075D91A69B82B00094431 /* Stripe iOS Example (Simple).entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Stripe iOS Example (Simple).entitlements"; sourceTree = "<group>"; };
|
||||
04D076191A69C14700094431 /* Stripe.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Stripe.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C11745D31C456C730029936F /* Stripe iOS Application Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Stripe iOS Application Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C11745D71C456C730029936F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
C11745DD1C456D6D0029936F /* Stripe iOS Application Tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Stripe iOS Application Tests-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
C11745DE1C456D6D0029936F /* STPPaymentCardTextFieldUITests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPaymentCardTextFieldUITests.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -49,6 +64,13 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
C11745D01C456C730029936F /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
|
@ -69,6 +91,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
042CA4131A685E8D00D778E7 /* Stripe iOS Example (Simple) */,
|
||||
C11745D41C456C730029936F /* Stripe iOS Application Tests */,
|
||||
04823F9F1A6849850098400B /* Frameworks */,
|
||||
04823F791A6849200098400B /* Products */,
|
||||
);
|
||||
|
@ -78,6 +101,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
04823F781A6849200098400B /* Stripe iOS Example (Simple).app */,
|
||||
C11745D31C456C730029936F /* Stripe iOS Application Tests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
|
@ -90,6 +114,16 @@
|
|||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C11745D41C456C730029936F /* Stripe iOS Application Tests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C11745DE1C456D6D0029936F /* STPPaymentCardTextFieldUITests.m */,
|
||||
C11745D71C456C730029936F /* Info.plist */,
|
||||
C11745DD1C456D6D0029936F /* Stripe iOS Application Tests-Bridging-Header.h */,
|
||||
);
|
||||
path = "Stripe iOS Application Tests";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
|
@ -111,13 +145,31 @@
|
|||
productReference = 04823F781A6849200098400B /* Stripe iOS Example (Simple).app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
C11745D21C456C730029936F /* Stripe iOS Application Tests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = C11745DC1C456C730029936F /* Build configuration list for PBXNativeTarget "Stripe iOS Application Tests" */;
|
||||
buildPhases = (
|
||||
C11745CF1C456C730029936F /* Sources */,
|
||||
C11745D01C456C730029936F /* Frameworks */,
|
||||
C11745D11C456C730029936F /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
C11745D91C456C730029936F /* PBXTargetDependency */,
|
||||
);
|
||||
name = "Stripe iOS Application Tests";
|
||||
productName = "Stripe iOS Application Tests";
|
||||
productReference = C11745D31C456C730029936F /* Stripe iOS Application Tests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
04823F701A6849200098400B /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0700;
|
||||
LastSwiftUpdateCheck = 0720;
|
||||
LastUpgradeCheck = 0710;
|
||||
ORGANIZATIONNAME = Stripe;
|
||||
TargetAttributes = {
|
||||
|
@ -132,6 +184,10 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
C11745D21C456C730029936F = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
TestTargetID = 04823F771A6849200098400B;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 04823F731A6849200098400B /* Build configuration list for PBXProject "Stripe iOS Example (Simple)" */;
|
||||
|
@ -148,6 +204,7 @@
|
|||
projectRoot = "";
|
||||
targets = (
|
||||
04823F771A6849200098400B /* Stripe iOS Example (Simple) */,
|
||||
C11745D21C456C730029936F /* Stripe iOS Application Tests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
@ -162,6 +219,13 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
C11745D11C456C730029936F /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
|
@ -174,8 +238,24 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
C11745CF1C456C730029936F /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C11745DF1C456D6D0029936F /* STPPaymentCardTextFieldUITests.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
C11745D91C456C730029936F /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 04823F771A6849200098400B /* Stripe iOS Example (Simple) */;
|
||||
targetProxy = C11745D81C456C730029936F /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
042CA4171A685E8D00D778E7 /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
|
@ -317,6 +397,42 @@
|
|||
};
|
||||
name = Release;
|
||||
};
|
||||
C11745DA1C456C730029936F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "Stripe iOS Application Tests/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.stripe.Stripe-iOS-Application-Tests";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Stripe iOS Application Tests/Stripe iOS Application Tests-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Stripe iOS Example (Simple).app/Stripe iOS Example (Simple)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C11745DB1C456C730029936F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "Stripe iOS Application Tests/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.stripe.Stripe-iOS-Application-Tests";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Stripe iOS Application Tests/Stripe iOS Application Tests-Bridging-Header.h";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Stripe iOS Example (Simple).app/Stripe iOS Example (Simple)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
|
@ -338,6 +454,14 @@
|
|||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C11745DC1C456C730029936F /* Build configuration list for PBXNativeTarget "Stripe iOS Application Tests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C11745DA1C456C730029936F /* Debug */,
|
||||
C11745DB1C456C730029936F /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 04823F701A6849200098400B /* Project object */;
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C11745D21C456C730029936F"
|
||||
BuildableName = "Stripe iOS Application Tests.xctest"
|
||||
BlueprintName = "Stripe iOS Application Tests"
|
||||
ReferencedContainer = "container:Stripe iOS Example (Simple).xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
|
@ -28,6 +28,16 @@
|
|||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C11745D21C456C730029936F"
|
||||
BuildableName = "Stripe iOS Application Tests.xctest"
|
||||
BlueprintName = "Stripe iOS Application Tests"
|
||||
ReferencedContainer = "container:Stripe iOS Example (Simple).xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
|
|
Loading…
Reference in New Issue