From 3bdab3c67fa13e84a51f4b7d9006b9a5371e9530 Mon Sep 17 00:00:00 2001 From: Joey Dong Date: Mon, 2 Jul 2018 14:13:08 -0700 Subject: [PATCH 1/7] Bump functional test card expiration date further into future --- Tests/Tests/STPCardFunctionalTest.m | 16 ++++++++-------- Tests/Tests/STPSourceFunctionalTest.m | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/Tests/STPCardFunctionalTest.m b/Tests/Tests/STPCardFunctionalTest.m index 2ee5b8a3d7c..b5ea278ab89 100644 --- a/Tests/Tests/STPCardFunctionalTest.m +++ b/Tests/Tests/STPCardFunctionalTest.m @@ -19,8 +19,8 @@ - (void)testCreateCardToken { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4242 4242 4242 4242"; - card.expMonth = 6; - card.expYear = 2018; + card.expMonth = 12; + card.expYear = 2050; card.currency = @"usd"; card.address.line1 = @"123 Fake Street"; card.address.line2 = @"Apartment 4"; @@ -41,8 +41,8 @@ - (void)testCreateCardToken { XCTAssertNotNil(token, @"token should not be nil"); XCTAssertNotNil(token.tokenId); - XCTAssertEqual(6U, token.card.expMonth); - XCTAssertEqual(2018U, token.card.expYear); + XCTAssertEqual(card.expMonth, token.card.expMonth); + XCTAssertEqual(card.expYear, token.card.expYear); XCTAssertEqualObjects(@"4242", token.card.last4); XCTAssertEqualObjects(@"usd", token.card.currency); }]; @@ -53,8 +53,8 @@ - (void)testCardTokenCreationWithInvalidParams { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4242 4242 4242 4241"; - card.expMonth = 6; - card.expYear = 2018; + card.expMonth = 12; + card.expYear = 2050; STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:@"pk_test_vOo1umqsYxSrP5UXfOeL3ecm"]; @@ -77,8 +77,8 @@ - (void)testInvalidKey { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4242 4242 4242 4242"; - card.expMonth = 6; - card.expYear = 2018; + card.expMonth = 12; + card.expYear = 2050; STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:@"not_a_valid_key_asdf"]; diff --git a/Tests/Tests/STPSourceFunctionalTest.m b/Tests/Tests/STPSourceFunctionalTest.m index 9db6a6244ee..4fe43aaec17 100644 --- a/Tests/Tests/STPSourceFunctionalTest.m +++ b/Tests/Tests/STPSourceFunctionalTest.m @@ -51,8 +51,8 @@ - (void)testCreateSource_bancontact { - (void)testCreateSource_card { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4242 4242 4242 4242"; - card.expMonth = 6; - card.expYear = 2018; + card.expMonth = 12; + card.expYear = 2050; card.currency = @"usd"; card.name = @"Jenny Rosen"; card.address.line1 = @"123 Fake Street"; @@ -288,8 +288,8 @@ - (void)testCreateSource_sofort { - (void)testCreateSource_threeDSecure { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4000000000003063"; - card.expMonth = 6; - card.expYear = 2018; + card.expMonth = 12; + card.expYear = 2050; card.currency = @"usd"; card.address.line1 = @"123 Fake Street"; card.address.line2 = @"Apartment 4"; From 7ef38f52441d9135323908be9fbd0d3fb8848309 Mon Sep 17 00:00:00 2001 From: Joey Dong Date: Mon, 2 Jul 2018 14:13:19 -0700 Subject: [PATCH 2/7] Add conditional check around iOS 10+ only constants --- Tests/Tests/STPColorUtilsTest.m | 60 ++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/Tests/Tests/STPColorUtilsTest.m b/Tests/Tests/STPColorUtilsTest.m index d772004053e..f85bba80039 100644 --- a/Tests/Tests/STPColorUtilsTest.m +++ b/Tests/Tests/STPColorUtilsTest.m @@ -75,12 +75,12 @@ - (void)testBuiltinColorsIsBright { - (void)testAllColorSpaces { // block to create & check brightness of color in a given color space - void (^testColorSpace)(const CFStringRef, BOOL) = ^(const CFStringRef colorSpaceName, BOOL expectedToBeBright) { + void (^testColorSpace)(NSString *, BOOL) = ^(NSString *colorSpaceName, BOOL expectedToBeBright) { // this a bright color in almost all color spaces CGFloat components[] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; UIColor *color = nil; - CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(colorSpaceName); + CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName((__bridge CFStringRef)colorSpaceName); if (colorSpace) { CGColorRef cgcolor = CGColorCreate(colorSpace, components); @@ -103,38 +103,42 @@ - (void)testAllColorSpaces { } }; - CFStringRef colorSpaceNames[] = { - kCGColorSpaceSRGB, - kCGColorSpaceDCIP3, - kCGColorSpaceROMMRGB, - kCGColorSpaceITUR_709, - kCGColorSpaceDisplayP3, - kCGColorSpaceITUR_2020, - kCGColorSpaceGenericRGB, - kCGColorSpaceGenericXYZ, - kCGColorSpaceLinearGray, - kCGColorSpaceLinearSRGB, - kCGColorSpaceGenericCMYK, - kCGColorSpaceGenericGray, - kCGColorSpaceACESCGLinear, - kCGColorSpaceAdobeRGB1998, - kCGColorSpaceExtendedGray, - kCGColorSpaceExtendedSRGB, - kCGColorSpaceGenericRGBLinear, - kCGColorSpaceExtendedLinearGray, - kCGColorSpaceExtendedLinearSRGB, - kCGColorSpaceGenericGrayGamma2_2, - }; + NSArray *colorSpaceNames = @[ + (__bridge NSString *)kCGColorSpaceSRGB, + (__bridge NSString *)kCGColorSpaceDCIP3, + (__bridge NSString *)kCGColorSpaceROMMRGB, + (__bridge NSString *)kCGColorSpaceITUR_709, + (__bridge NSString *)kCGColorSpaceDisplayP3, + (__bridge NSString *)kCGColorSpaceITUR_2020, + (__bridge NSString *)kCGColorSpaceGenericRGB, + (__bridge NSString *)kCGColorSpaceGenericXYZ, + (__bridge NSString *)kCGColorSpaceLinearSRGB, + (__bridge NSString *)kCGColorSpaceGenericCMYK, + (__bridge NSString *)kCGColorSpaceGenericGray, + (__bridge NSString *)kCGColorSpaceACESCGLinear, + (__bridge NSString *)kCGColorSpaceAdobeRGB1998, + (__bridge NSString *)kCGColorSpaceExtendedGray, + (__bridge NSString *)kCGColorSpaceExtendedSRGB, + (__bridge NSString *)kCGColorSpaceGenericRGBLinear, + (__bridge NSString *)kCGColorSpaceExtendedLinearSRGB, + (__bridge NSString *)kCGColorSpaceGenericGrayGamma2_2, + ]; + + if (@available(iOS 10.0, *)) { + colorSpaceNames = [colorSpaceNames arrayByAddingObjectsFromArray:@[ + (__bridge NSString *)kCGColorSpaceLinearGray, + (__bridge NSString *)kCGColorSpaceExtendedLinearGray, + ]]; + } - int colorSpaceCount = sizeof(colorSpaceNames) / sizeof(colorSpaceNames[0]); - for (int i = 0; i < colorSpaceCount; ++i) { + for (NSString *name in colorSpaceNames) { // CMYK is the only one where all 1's results in a dark color - testColorSpace(colorSpaceNames[i], colorSpaceNames[i] != kCGColorSpaceGenericCMYK); + testColorSpace(name, name != (__bridge NSString *)kCGColorSpaceGenericCMYK); } if (@available(iOS 11.0, *)) { // in LAB all 1's is dark - testColorSpace(kCGColorSpaceGenericLab, NO); + testColorSpace((__bridge NSString *)kCGColorSpaceGenericLab, NO); } } From fd1a3e803d4d049e8df62e5c316038b7172541be Mon Sep 17 00:00:00 2001 From: Joey Dong Date: Mon, 2 Jul 2018 14:13:23 -0700 Subject: [PATCH 3/7] Fix STPRedirectContextTest compatibility with iOS 9 --- Tests/Tests/STPRedirectContextTest.m | 34 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Tests/Tests/STPRedirectContextTest.m b/Tests/Tests/STPRedirectContextTest.m index 7d082d480fe..0e9b9948a29 100644 --- a/Tests/Tests/STPRedirectContextTest.m +++ b/Tests/Tests/STPRedirectContextTest.m @@ -458,9 +458,14 @@ - (void)testNativeRedirectSupportingSourceFlow_validNativeURL { id applicationMock = OCMClassMock([UIApplication class]); OCMStub([applicationMock sharedApplication]).andReturn(applicationMock); - OCMStub([applicationMock openURL:[OCMArg any] - options:[OCMArg any] - completionHandler:([OCMArg invokeBlockWithArgs:@YES, nil])]); + if (@available(iOS 10, *)) { + OCMStub([applicationMock openURL:[OCMArg any] + options:[OCMArg any] + completionHandler:([OCMArg invokeBlockWithArgs:@YES, nil])]); + } + else { + OCMStub([applicationMock openURL:[OCMArg any]]).andReturn(YES); + } OCMReject([sut startSafariViewControllerRedirectFlowFromViewController:[OCMArg any]]); OCMReject([sut startSafariAppRedirectFlow]); @@ -468,9 +473,14 @@ - (void)testNativeRedirectSupportingSourceFlow_validNativeURL { id mockVC = OCMClassMock([UIViewController class]); [sut startRedirectFlowFromViewController:mockVC]; - OCMVerify([applicationMock openURL:[OCMArg isEqual:sourceURL] - options:[OCMArg isEqual:@{}] - completionHandler:[OCMArg isNotNil]]); + if (@available(iOS 10, *)) { + OCMVerify([applicationMock openURL:[OCMArg isEqual:sourceURL] + options:[OCMArg isEqual:@{}] + completionHandler:[OCMArg isNotNil]]); + } + else { + OCMVerify([applicationMock openURL:[OCMArg isEqual:sourceURL]]); + } [sut unsubscribeFromNotifications]; } @@ -491,9 +501,15 @@ - (void)testNativeRedirectSupportingSourceFlow_invalidNativeURL { id applicationMock = OCMClassMock([UIApplication class]); OCMStub([applicationMock sharedApplication]).andReturn(applicationMock); - OCMReject([applicationMock openURL:[OCMArg any] - options:[OCMArg any] - completionHandler:[OCMArg any]]); + if (@available(iOS 10, *)) { + OCMReject([applicationMock openURL:[OCMArg any] + options:[OCMArg any] + completionHandler:[OCMArg any]]); + } + else { + OCMReject([applicationMock openURL:[OCMArg any]]); + } + id mockVC = OCMClassMock([UIViewController class]); [sut startRedirectFlowFromViewController:mockVC]; From 4a00bf081e544ae1bc32d250626f706708f586e4 Mon Sep 17 00:00:00 2001 From: Joey Dong Date: Mon, 2 Jul 2018 14:13:27 -0700 Subject: [PATCH 4/7] Execute tests on all supported iOS versions and architectures --- .travis.yml | 2 + ci_scripts/run_builds.sh | 63 ++++++++++++++++++++++++ ci_scripts/run_tests.sh | 104 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 161 insertions(+), 8 deletions(-) create mode 100755 ci_scripts/run_builds.sh diff --git a/.travis.yml b/.travis.yml index a29e2447806..5f4d199048f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: - TEST_TYPE=installation_cocoapods_frameworks - TEST_TYPE=lint - TEST_TYPE=tests + - TEST_TYPE=builds - TEST_TYPE=analyzer - TEST_TYPE=documentation @@ -28,6 +29,7 @@ script: - "./ci_scripts/check_resource_bundle.rb" - '[ "$TEST_TYPE" != lint ] || ./ci_scripts/check_fauxpas.sh' - '[ "$TEST_TYPE" != tests ] || travis_retry ./ci_scripts/run_tests.sh' +- '[ "$TEST_TYPE" != builds ] || travis_retry ./ci_scripts/run_builds.sh' - '[ "$TEST_TYPE" != analyzer ] || ./ci_scripts/run_analyzer.sh' - '[ "$TEST_TYPE" != installation_cocoapods_objc ] || ./Tests/installation_tests/cocoapods/without_frameworks_objc/test.sh' - '[ "$TEST_TYPE" != installation_cocoapods_frameworks_objc ] || ./Tests/installation_tests/cocoapods/with_frameworks_objc/test.sh' diff --git a/ci_scripts/run_builds.sh b/ci_scripts/run_builds.sh new file mode 100755 index 00000000000..109377cd928 --- /dev/null +++ b/ci_scripts/run_builds.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +function info { + echo "[$(basename "${0}")] [INFO] ${1}" +} + +function die { + echo "[$(basename "${0}")] [ERROR] ${1}" + exit 1 +} + +# Verify xcpretty is installed +if ! command -v xcpretty > /dev/null; then + if [[ "${CI}" != "true" ]]; then + die "Please install xcpretty: https://github.com/supermarin/xcpretty#installation" + fi + + info "Installing xcpretty..." + gem install xcpretty --no-ri --no-rdoc || die "Executing \`gem install xcpretty\` failed" +fi + +# Install sample app dependencies +info "Installing sample app dependencies..." + +cd "Example" || die "Executing \`cd\` failed" +carthage bootstrap --platform iOS +carthage_exit_code="$?" +cd .. || die "Executing \`cd\` failed" + +if [[ "${carthage_exit_code}" != 0 ]]; then + die "Executing carthage failed with status code: ${carthage_exit_code}" +fi + +# Execute sample app builds (iPhone 6, iOS 11.x) +info "Executing sample app builds (iPhone 6, iOS 11.x)..." + +xcodebuild build \ + -workspace "Stripe.xcworkspace" \ + -scheme "Standard Integration (Swift)" \ + -sdk "iphonesimulator" \ + -destination "platform=iOS Simulator,name=iPhone 6,OS=11.2" \ + | xcpretty + +exit_code="${PIPESTATUS[0]}" + +if [[ "${exit_code}" != 0 ]]; then + die "xcodebuild exited with non-zero status code: ${exit_code}" +fi + +xcodebuild build \ + -workspace "Stripe.xcworkspace" \ + -scheme "Custom Integration (ObjC)" \ + -sdk "iphonesimulator" \ + -destination "platform=iOS Simulator,name=iPhone 6,OS=11.2" \ + | xcpretty + +exit_code="${PIPESTATUS[0]}" + +if [[ "${exit_code}" != 0 ]]; then + die "xcodebuild exited with non-zero status code: ${exit_code}" +fi + +info "All good!" diff --git a/ci_scripts/run_tests.sh b/ci_scripts/run_tests.sh index 1062cfe4a78..2120e4af4e6 100755 --- a/ci_scripts/run_tests.sh +++ b/ci_scripts/run_tests.sh @@ -1,10 +1,98 @@ -set -euf -o pipefail +#!/bin/bash -carthage bootstrap --platform ios --configuration Release --no-use-binaries -cd Example; carthage bootstrap --platform ios; cd .. +function info { + echo "[$(basename "${0}")] [INFO] ${1}" +} -gem install xcpretty --no-ri --no-rdoc -xcodebuild clean build build-for-testing -workspace Stripe.xcworkspace -scheme "StripeiOS" -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' | xcpretty -c -xcodebuild test-without-building -workspace Stripe.xcworkspace -scheme "StripeiOS" -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' | xcpretty -c -xcodebuild build -workspace Stripe.xcworkspace -scheme "Standard Integration (Swift)" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' | xcpretty -c -xcodebuild build -workspace Stripe.xcworkspace -scheme "Custom Integration (ObjC)" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' | xcpretty -c +function die { + echo "[$(basename "${0}")] [ERROR] ${1}" + exit 1 +} + +# Verify xcpretty is installed +if ! command -v xcpretty > /dev/null; then + if [[ "${CI}" != "true" ]]; then + die "Please install xcpretty: https://github.com/supermarin/xcpretty#installation" + fi + + info "Installing xcpretty..." + gem install xcpretty --no-ri --no-rdoc || die "Executing \`gem install xcpretty\` failed" +fi + +# Install test dependencies +info "Installing test dependencies..." + +carthage bootstrap --platform iOS --configuration Release --no-use-binaries +carthage_exit_code="$?" + +if [[ "${carthage_exit_code}" != 0 ]]; then + die "Executing carthage failed with status code: ${carthage_exit_code}" +fi + +# Execute tests (iPhone 6 @ iOS 11.2) +info "Executing tests (iPhone 6 @ iOS 11.2)..." + +xcodebuild clean test \ + -workspace "Stripe.xcworkspace" \ + -scheme "StripeiOS" \ + -configuration "Debug" \ + -sdk "iphonesimulator" \ + -destination "platform=iOS Simulator,name=iPhone 6,OS=11.2" \ + | xcpretty + +exit_code="${PIPESTATUS[0]}" + +if [[ "${exit_code}" != 0 ]]; then + die "xcodebuild exited with non-zero status code: ${exit_code}" +fi + +# Execute tests on legacy devices (iPhone 6 @ iOS 10.x, iPhone 6 @ iOS 9.x) +# - Skips snapshot tests because they're recorded for the iPhone 6 on the newest iOS version only +# - Not sure why tests STPImageLibraryTest fail on older iOS versions +info "Executing tests on legacy devices (iPhone 6 @ iOS 10.x, iPhone 6 @ iOS 9.x)..." + +xcodebuild clean test \ + -workspace "Stripe.xcworkspace" \ + -scheme "StripeiOS" \ + -configuration "Debug" \ + -sdk "iphonesimulator" \ + -destination "platform=iOS Simulator,name=iPhone 6,OS=10.3.1" \ + -destination "platform=iOS Simulator,name=iPhone 6,OS=9.3" \ + -skip-testing:"StripeiOS Tests/STPAddCardViewControllerLocalizationTests" \ + -skip-testing:"StripeiOS Tests/STPPaymentMethodsViewControllerLocalizationTests" \ + -skip-testing:"StripeiOS Tests/STPShippingAddressViewControllerLocalizationTests" \ + -skip-testing:"StripeiOS Tests/STPShippingMethodsViewControllerLocalizationTests" \ + -skip-testing:"StripeiOS Tests/STPImageLibraryTest" \ + | xcpretty + +exit_code="${PIPESTATUS[0]}" + +if [[ "${exit_code}" != 0 ]]; then + die "xcodebuild exited with non-zero status code: ${exit_code}" +fi + +# Execute tests on 32-bit device (iPhone 4s @ iOS 9.x) +# - Skips snapshot tests because they're recorded for the iPhone 6 on the newest iOS version only +# - Not sure why tests STPImageLibraryTest fail on older iOS versions +info "Executing tests on 32-bit device (iPhone 4s @ iOS 9.x)..." + +xcodebuild clean test \ + -workspace "Stripe.xcworkspace" \ + -scheme "StripeiOS" \ + -configuration "Debug" \ + -sdk "iphonesimulator" \ + -destination "platform=iOS Simulator,name=iPhone 4s,OS=9.3" \ + -skip-testing:"StripeiOS Tests/STPAddCardViewControllerLocalizationTests" \ + -skip-testing:"StripeiOS Tests/STPPaymentMethodsViewControllerLocalizationTests" \ + -skip-testing:"StripeiOS Tests/STPShippingAddressViewControllerLocalizationTests" \ + -skip-testing:"StripeiOS Tests/STPShippingMethodsViewControllerLocalizationTests" \ + -skip-testing:"StripeiOS Tests/STPImageLibraryTest" \ + | xcpretty + +exit_code="${PIPESTATUS[0]}" + +if [[ "${exit_code}" != 0 ]]; then + die "xcodebuild exited with non-zero status code: ${exit_code}" +fi + +info "All good!" From 5084fd6435116a7cdebcff6ed0bab6dc7363c184 Mon Sep 17 00:00:00 2001 From: Joey Dong Date: Mon, 9 Jul 2018 16:01:52 -0700 Subject: [PATCH 5/7] Revert "Bump functional test card expiration date further into future" This reverts commit 3bdab3c67fa13e84a51f4b7d9006b9a5371e9530. --- Tests/Tests/STPCardFunctionalTest.m | 16 ++++++++-------- Tests/Tests/STPSourceFunctionalTest.m | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/Tests/STPCardFunctionalTest.m b/Tests/Tests/STPCardFunctionalTest.m index b5ea278ab89..2ee5b8a3d7c 100644 --- a/Tests/Tests/STPCardFunctionalTest.m +++ b/Tests/Tests/STPCardFunctionalTest.m @@ -19,8 +19,8 @@ - (void)testCreateCardToken { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4242 4242 4242 4242"; - card.expMonth = 12; - card.expYear = 2050; + card.expMonth = 6; + card.expYear = 2018; card.currency = @"usd"; card.address.line1 = @"123 Fake Street"; card.address.line2 = @"Apartment 4"; @@ -41,8 +41,8 @@ - (void)testCreateCardToken { XCTAssertNotNil(token, @"token should not be nil"); XCTAssertNotNil(token.tokenId); - XCTAssertEqual(card.expMonth, token.card.expMonth); - XCTAssertEqual(card.expYear, token.card.expYear); + XCTAssertEqual(6U, token.card.expMonth); + XCTAssertEqual(2018U, token.card.expYear); XCTAssertEqualObjects(@"4242", token.card.last4); XCTAssertEqualObjects(@"usd", token.card.currency); }]; @@ -53,8 +53,8 @@ - (void)testCardTokenCreationWithInvalidParams { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4242 4242 4242 4241"; - card.expMonth = 12; - card.expYear = 2050; + card.expMonth = 6; + card.expYear = 2018; STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:@"pk_test_vOo1umqsYxSrP5UXfOeL3ecm"]; @@ -77,8 +77,8 @@ - (void)testInvalidKey { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4242 4242 4242 4242"; - card.expMonth = 12; - card.expYear = 2050; + card.expMonth = 6; + card.expYear = 2018; STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:@"not_a_valid_key_asdf"]; diff --git a/Tests/Tests/STPSourceFunctionalTest.m b/Tests/Tests/STPSourceFunctionalTest.m index 4fe43aaec17..9db6a6244ee 100644 --- a/Tests/Tests/STPSourceFunctionalTest.m +++ b/Tests/Tests/STPSourceFunctionalTest.m @@ -51,8 +51,8 @@ - (void)testCreateSource_bancontact { - (void)testCreateSource_card { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4242 4242 4242 4242"; - card.expMonth = 12; - card.expYear = 2050; + card.expMonth = 6; + card.expYear = 2018; card.currency = @"usd"; card.name = @"Jenny Rosen"; card.address.line1 = @"123 Fake Street"; @@ -288,8 +288,8 @@ - (void)testCreateSource_sofort { - (void)testCreateSource_threeDSecure { STPCardParams *card = [[STPCardParams alloc] init]; card.number = @"4000000000003063"; - card.expMonth = 12; - card.expYear = 2050; + card.expMonth = 6; + card.expYear = 2018; card.currency = @"usd"; card.address.line1 = @"123 Fake Street"; card.address.line2 = @"Apartment 4"; From 2fc6b5bce276667eef6991cabe0dceda1792f182 Mon Sep 17 00:00:00 2001 From: Joey Dong Date: Mon, 9 Jul 2018 16:12:33 -0700 Subject: [PATCH 6/7] Test iOS 10 only color spaces in separate conditional branch instead of trying to append to overall array --- Tests/Tests/STPColorUtilsTest.m | 61 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/Tests/Tests/STPColorUtilsTest.m b/Tests/Tests/STPColorUtilsTest.m index f85bba80039..42c36d8ad23 100644 --- a/Tests/Tests/STPColorUtilsTest.m +++ b/Tests/Tests/STPColorUtilsTest.m @@ -75,12 +75,12 @@ - (void)testBuiltinColorsIsBright { - (void)testAllColorSpaces { // block to create & check brightness of color in a given color space - void (^testColorSpace)(NSString *, BOOL) = ^(NSString *colorSpaceName, BOOL expectedToBeBright) { + void (^testColorSpace)(const CFStringRef, BOOL) = ^(const CFStringRef colorSpaceName, BOOL expectedToBeBright) { // this a bright color in almost all color spaces CGFloat components[] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; UIColor *color = nil; - CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName((__bridge CFStringRef)colorSpaceName); + CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(colorSpaceName); if (colorSpace) { CGColorRef cgcolor = CGColorCreate(colorSpace, components); @@ -103,42 +103,41 @@ - (void)testAllColorSpaces { } }; - NSArray *colorSpaceNames = @[ - (__bridge NSString *)kCGColorSpaceSRGB, - (__bridge NSString *)kCGColorSpaceDCIP3, - (__bridge NSString *)kCGColorSpaceROMMRGB, - (__bridge NSString *)kCGColorSpaceITUR_709, - (__bridge NSString *)kCGColorSpaceDisplayP3, - (__bridge NSString *)kCGColorSpaceITUR_2020, - (__bridge NSString *)kCGColorSpaceGenericRGB, - (__bridge NSString *)kCGColorSpaceGenericXYZ, - (__bridge NSString *)kCGColorSpaceLinearSRGB, - (__bridge NSString *)kCGColorSpaceGenericCMYK, - (__bridge NSString *)kCGColorSpaceGenericGray, - (__bridge NSString *)kCGColorSpaceACESCGLinear, - (__bridge NSString *)kCGColorSpaceAdobeRGB1998, - (__bridge NSString *)kCGColorSpaceExtendedGray, - (__bridge NSString *)kCGColorSpaceExtendedSRGB, - (__bridge NSString *)kCGColorSpaceGenericRGBLinear, - (__bridge NSString *)kCGColorSpaceExtendedLinearSRGB, - (__bridge NSString *)kCGColorSpaceGenericGrayGamma2_2, - ]; + CFStringRef colorSpaceNames[] = { + kCGColorSpaceSRGB, + kCGColorSpaceDCIP3, + kCGColorSpaceROMMRGB, + kCGColorSpaceITUR_709, + kCGColorSpaceDisplayP3, + kCGColorSpaceITUR_2020, + kCGColorSpaceGenericRGB, + kCGColorSpaceGenericXYZ, + kCGColorSpaceLinearSRGB, + kCGColorSpaceGenericCMYK, + kCGColorSpaceGenericGray, + kCGColorSpaceACESCGLinear, + kCGColorSpaceAdobeRGB1998, + kCGColorSpaceExtendedGray, + kCGColorSpaceExtendedSRGB, + kCGColorSpaceGenericRGBLinear, + kCGColorSpaceExtendedLinearSRGB, + kCGColorSpaceGenericGrayGamma2_2, + }; - if (@available(iOS 10.0, *)) { - colorSpaceNames = [colorSpaceNames arrayByAddingObjectsFromArray:@[ - (__bridge NSString *)kCGColorSpaceLinearGray, - (__bridge NSString *)kCGColorSpaceExtendedLinearGray, - ]]; + int colorSpaceCount = sizeof(colorSpaceNames) / sizeof(colorSpaceNames[0]); + for (int i = 0; i < colorSpaceCount; ++i) { + // CMYK is the only one where all 1's results in a dark color + testColorSpace(colorSpaceNames[i], colorSpaceNames[i] != kCGColorSpaceGenericCMYK); } - for (NSString *name in colorSpaceNames) { - // CMYK is the only one where all 1's results in a dark color - testColorSpace(name, name != (__bridge NSString *)kCGColorSpaceGenericCMYK); + if (@available(iOS 10.0, *)) { + testColorSpace(kCGColorSpaceLinearGray, YES); + testColorSpace(kCGColorSpaceExtendedLinearGray, YES); } if (@available(iOS 11.0, *)) { // in LAB all 1's is dark - testColorSpace((__bridge NSString *)kCGColorSpaceGenericLab, NO); + testColorSpace(kCGColorSpaceGenericLab, NO); } } From 2321d4975814cd6a85081f0762fe767ecaa4a7d0 Mon Sep 17 00:00:00 2001 From: Joey Dong Date: Mon, 9 Jul 2018 16:32:48 -0700 Subject: [PATCH 7/7] Combine 32-bit and 64-bit test steps by setting `ONLY_ACTIVE_ARCH=NO` --- ci_scripts/run_tests.sh | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/ci_scripts/run_tests.sh b/ci_scripts/run_tests.sh index 2120e4af4e6..0e941348d3b 100755 --- a/ci_scripts/run_tests.sh +++ b/ci_scripts/run_tests.sh @@ -46,10 +46,11 @@ if [[ "${exit_code}" != 0 ]]; then die "xcodebuild exited with non-zero status code: ${exit_code}" fi -# Execute tests on legacy devices (iPhone 6 @ iOS 10.x, iPhone 6 @ iOS 9.x) +# Execute tests on legacy devices (iPhone 6 @ iOS 10.x, iPhone 6 @ iOS 9.x, iPhone 4s @ iOS 9.x) # - Skips snapshot tests because they're recorded for the iPhone 6 on the newest iOS version only # - Not sure why tests STPImageLibraryTest fail on older iOS versions -info "Executing tests on legacy devices (iPhone 6 @ iOS 10.x, iPhone 6 @ iOS 9.x)..." +# - Set `ONLY_ACTIVE_ARCH=NO` to build both 32-bit and 64-bit products +info "Executing tests on legacy devices (iPhone 6 @ iOS 10.x, iPhone 6 @ iOS 9.x, iPhone 4s @ iOS 9.x)..." xcodebuild clean test \ -workspace "Stripe.xcworkspace" \ @@ -58,35 +59,13 @@ xcodebuild clean test \ -sdk "iphonesimulator" \ -destination "platform=iOS Simulator,name=iPhone 6,OS=10.3.1" \ -destination "platform=iOS Simulator,name=iPhone 6,OS=9.3" \ - -skip-testing:"StripeiOS Tests/STPAddCardViewControllerLocalizationTests" \ - -skip-testing:"StripeiOS Tests/STPPaymentMethodsViewControllerLocalizationTests" \ - -skip-testing:"StripeiOS Tests/STPShippingAddressViewControllerLocalizationTests" \ - -skip-testing:"StripeiOS Tests/STPShippingMethodsViewControllerLocalizationTests" \ - -skip-testing:"StripeiOS Tests/STPImageLibraryTest" \ - | xcpretty - -exit_code="${PIPESTATUS[0]}" - -if [[ "${exit_code}" != 0 ]]; then - die "xcodebuild exited with non-zero status code: ${exit_code}" -fi - -# Execute tests on 32-bit device (iPhone 4s @ iOS 9.x) -# - Skips snapshot tests because they're recorded for the iPhone 6 on the newest iOS version only -# - Not sure why tests STPImageLibraryTest fail on older iOS versions -info "Executing tests on 32-bit device (iPhone 4s @ iOS 9.x)..." - -xcodebuild clean test \ - -workspace "Stripe.xcworkspace" \ - -scheme "StripeiOS" \ - -configuration "Debug" \ - -sdk "iphonesimulator" \ -destination "platform=iOS Simulator,name=iPhone 4s,OS=9.3" \ -skip-testing:"StripeiOS Tests/STPAddCardViewControllerLocalizationTests" \ -skip-testing:"StripeiOS Tests/STPPaymentMethodsViewControllerLocalizationTests" \ -skip-testing:"StripeiOS Tests/STPShippingAddressViewControllerLocalizationTests" \ -skip-testing:"StripeiOS Tests/STPShippingMethodsViewControllerLocalizationTests" \ -skip-testing:"StripeiOS Tests/STPImageLibraryTest" \ + ONLY_ACTIVE_ARCH=NO \ | xcpretty exit_code="${PIPESTATUS[0]}"