diff --git a/.ruby-version b/.ruby-version index 59aa62c..2714f53 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.4.5 +2.6.4 diff --git a/.travis.yml b/.travis.yml index 6691c5a..e0c2ac5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: swift -osx_image: xcode10.2 +osx_image: xcode11.3 xcode_workspace: Example/PerspectiveTransform.xcworkspace xcode_scheme: Example -xcode_sdk: iphonesimulator12.2 +xcode_sdk: iphonesimulator13.2 git: depth: 1 # use 1, as false cause travis lint server 500 exception cache: @@ -25,12 +25,12 @@ matrix: - git diff --exit-code # Outdated Bundle dependencies found, please run 'bundle update' and checkin changes - bundle exec pod lib lint || bundle exec pod lib lint --verbose --no-clean - name: With coverage report - env: XCODE_DESNITATION='platform=iOS Simulator,name=iPhone X' CACHE_NAME=iOS + env: XCODE_DESTINATION='platform=iOS Simulator,name=iPhone 11 Pro' CACHE_NAME=iOS after_success: - bash <(curl -s 'https://codecov.io/bash') -Z -J '^PerspectiveTransform$' -X gcov -X fix - name: Mac OS xcode_scheme: OpenCV Tests - env: XCODE_DESNITATION='platform=macos' CACHE_NAME=macOS + env: XCODE_DESTINATION='platform=macos' CACHE_NAME=macOS before_script: ./Example/OpenCV-OSX-Tests/install-opencv.sh cache: bundler: true @@ -93,13 +93,13 @@ matrix: tags: true before_install: - bundle -v || gem install bundler - - ls -la Example/Pods/Manifest.lock && echo Skipping cocoapods repo update || git -C ~/.cocoapods/repos/master/ pull --quiet + - ls -la Example/Pods/Manifest.lock && echo Skipping cocoapods repo update || pod install --project-directory=Example script: - - set -o pipefail && xcodebuild test -workspace "$TRAVIS_XCODE_WORKSPACE" -scheme "$TRAVIS_XCODE_SCHEME" -destination "$XCODE_DESNITATION" | bundle exec xcpretty -f `bundle exec xcpretty-travis-formatter` + - set -o pipefail && xcodebuild test -workspace "$TRAVIS_XCODE_WORKSPACE" -scheme "$TRAVIS_XCODE_SCHEME" -destination "$XCODE_DESTINATION" | bundle exec xcpretty -f `bundle exec xcpretty-travis-formatter` env: - - XCODE_DESNITATION='platform=iOS Simulator,name=iPhone SE' CACHE_NAME=iOS - - XCODE_DESNITATION='platform=iOS Simulator,name=iPhone 8 Plus' CACHE_NAME=iOS - - XCODE_DESNITATION='platform=iOS Simulator,name=iPhone 8' CACHE_NAME=iOS + - XCODE_DESTINATION='platform=iOS Simulator,name=iPhone 11' CACHE_NAME=iOS + - XCODE_DESTINATION='platform=iOS Simulator,name=iPhone 11 Pro Max' CACHE_NAME=iOS + - XCODE_DESTINATION='platform=iOS Simulator,name=iPhone 8 Plus' CACHE_NAME=iOS branches: except: - circleci diff --git a/Example/PerspectiveTransform.xcworkspace/xcshareddata/xcschemes/Example.xcscheme b/Example/PerspectiveTransform.xcworkspace/xcshareddata/xcschemes/Example.xcscheme index ce1f71f..633d5d5 100644 --- a/Example/PerspectiveTransform.xcworkspace/xcshareddata/xcschemes/Example.xcscheme +++ b/Example/PerspectiveTransform.xcworkspace/xcshareddata/xcschemes/Example.xcscheme @@ -1,6 +1,6 @@ + onlyGenerateCoverageForSpecifiedTargets = "YES"> + + + + @@ -76,17 +85,6 @@ - - - - - - - - + onlyGenerateCoverageForSpecifiedTargets = "YES"> @@ -51,8 +51,6 @@ - - - - '../' @@ -13,7 +13,7 @@ target 'Example' do DevelopmentPodAndDependencies() def SwiftTestingPods - pod 'Quick', :inhibit_warnings => true + pod 'Quick' pod 'Nimble' end diff --git a/Example/Podfile.lock b/Example/Podfile.lock index cb1fbe2..e052bcd 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,18 +1,18 @@ PODS: - ImageCoordinateSpace (1.1) - - iOSSnapshotTestCase (6.1.0): - - iOSSnapshotTestCase/SwiftSupport (= 6.1.0) - - iOSSnapshotTestCase/Core (6.1.0) - - iOSSnapshotTestCase/SwiftSupport (6.1.0): + - iOSSnapshotTestCase (6.2.0): + - iOSSnapshotTestCase/SwiftSupport (= 6.2.0) + - iOSSnapshotTestCase/Core (6.2.0) + - iOSSnapshotTestCase/SwiftSupport (6.2.0): - iOSSnapshotTestCase/Core - - Nimble (8.0.2) - - Nimble-Snapshots (8.0.0): - - Nimble-Snapshots/Core (= 8.0.0) - - Nimble-Snapshots/Core (8.0.0): + - Nimble (8.0.5) + - Nimble-Snapshots (8.1.0): + - Nimble-Snapshots/Core (= 8.1.0) + - Nimble-Snapshots/Core (8.1.0): - iOSSnapshotTestCase (~> 6.0) - Nimble (~> 8.0) - PerspectiveTransform (1.0) - - Quick (2.1.0) + - Quick (2.2.0) DEPENDENCIES: - ImageCoordinateSpace @@ -22,7 +22,7 @@ DEPENDENCIES: - Quick SPEC REPOS: - https://github.com/CocoaPods/Specs.git: + trunk: - ImageCoordinateSpace - iOSSnapshotTestCase - Nimble @@ -35,12 +35,12 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: ImageCoordinateSpace: 9e560a43a97375371f22343bb47e2c7e7fc428ae - iOSSnapshotTestCase: 30d540b0c8feb9d7f8ff97acc25a3804b48ee264 - Nimble: 622629381bda1dd5678162f21f1368cec7cbba60 - Nimble-Snapshots: 8ec63f41ce6c7229a17be9a64edbc123b181f75b - PerspectiveTransform: 77d4f6b4ef5b8dbf5472afb8864ee3a74fffa193 - Quick: 4be43f6634acfa727dd106bdf3929ce125ffa79d + iOSSnapshotTestCase: 9ab44cb5aa62b84d31847f40680112e15ec579a6 + Nimble: 4ab1aeb9b45553c75b9687196b0fa0713170a332 + Nimble-Snapshots: 3a624ceb92ec1f110da64933d1536199910e885a + PerspectiveTransform: 03b9bc0a363917602cd660d7d8fe031f549c73d3 + Quick: 7fb19e13be07b5dfb3b90d4f9824c855a11af40e -PODFILE CHECKSUM: 80ff60e539c07a49578d282438bd9e678f55ceff +PODFILE CHECKSUM: 1022d64c64e11ea237eb8911f12da68da807a763 -COCOAPODS: 1.8.0.beta.1 +COCOAPODS: 1.8.4 diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PerspectiveTransform.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PerspectiveTransform.xcscheme index 3dd6c07..e1965bf 100644 --- a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PerspectiveTransform.xcscheme +++ b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/PerspectiveTransform.xcscheme @@ -1,6 +1,6 @@ @@ -26,13 +26,22 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" codeCoverageEnabled = "YES" - onlyGenerateCoverageForSpecifiedTargets = "YES" - shouldUseLaunchSchemeArgsEnv = "YES"> + onlyGenerateCoverageForSpecifiedTargets = "YES"> + + + + @@ -51,17 +60,6 @@ - - - - - - - - diff --git a/Example/Specs/CALayerTransformSpec.swift b/Example/Specs/CALayerTransformSpec.swift index 7b6856c..ea7b9ec 100644 --- a/Example/Specs/CALayerTransformSpec.swift +++ b/Example/Specs/CALayerTransformSpec.swift @@ -10,7 +10,7 @@ class CALayerTransformSpec: QuickSpec { it("should have x,y,z") { let transform = CATransform3DMakeTranslation(1, 2, 3) - var translate = transform.component(for: .translation) + let translate = transform.component(for: .translation) expect(translate.x) == 1 expect(translate.y) == 2 @@ -22,7 +22,7 @@ class CALayerTransformSpec: QuickSpec { context("around one axis") { it("should match rotation.x component") { let transform = CATransform3DMakeRotation(0.1234, 1, 0, 0) - var rotate = transform.component(for: .rotation) + let rotate = transform.component(for: .rotation) expect(rotate.x) == 0.1234 expect(rotate.y) == 0 @@ -42,7 +42,7 @@ class CALayerTransformSpec: QuickSpec { context("large angles") { it("should be wrapped by asin") { let transform = CATransform3DMakeRotation(100, 1, 0, 0) - var rotate = transform.layerRotation() + let rotate = transform.layerRotation() expect(rotate.x) == asin(sin(100)) expect(rotate.y) == 0 diff --git a/Example/Specs/CATransform3D+MatrixPerformanceTest.swift b/Example/Specs/CATransform3D+MatrixPerformanceTest.swift index 796472d..4b0d73c 100644 --- a/Example/Specs/CATransform3D+MatrixPerformanceTest.swift +++ b/Example/Specs/CATransform3D+MatrixPerformanceTest.swift @@ -12,7 +12,7 @@ import simd class CATransform3DMatrixPerformanceTest: XCTestCase { let m4x4 = double4x4((1...4).map { row in - double4((1...4).map {Double(10 * row + $0)}) + SIMD4((1...4).map {Double(10 * row + $0)}) }) let iterations = 100000 diff --git a/Example/Specs/CATransform3D+MatrixSpec.swift b/Example/Specs/CATransform3D+MatrixSpec.swift index e14af24..14c2bb6 100644 --- a/Example/Specs/CATransform3D+MatrixSpec.swift +++ b/Example/Specs/CATransform3D+MatrixSpec.swift @@ -9,8 +9,8 @@ class CATransform3D_MatrixSpec: QuickSpec { var m4x4: double4x4! beforeEach { - let columns: [double4] = (1...4).map { row in - double4((1...4).map {Double(10 * row + $0)}) + let columns: [SIMD4] = (1...4).map { row in + SIMD4((1...4).map {Double(10 * row + $0)}) } m4x4 = double4x4(columns) } diff --git a/Example/Specs/CATransform3Dfrom2DSpec.swift b/Example/Specs/CATransform3Dfrom2DSpec.swift index f9a95af..d456b56 100644 --- a/Example/Specs/CATransform3Dfrom2DSpec.swift +++ b/Example/Specs/CATransform3Dfrom2DSpec.swift @@ -47,11 +47,11 @@ class CATransform3Dfrom2DSpec: QuickSpec { context("layer") { it("should have components") { let transform = CATransform3D(matrix.to3d()) - var scale = transform.component(for: .scale) + let scale = transform.component(for: .scale) let madeScale = CATransform3DMakeScale(CGFloat(scale.x), CGFloat(scale.y), CGFloat(scale.z)) print("madeScale:", madeScale) - var translate = transform.component(for: .translation) + let translate = transform.component(for: .translation) let madeTranslation = CATransform3DMakeTranslation(CGFloat(translate.x), CGFloat(translate.y), CGFloat(translate.z)) print("madeTranslation:", madeTranslation) diff --git a/Example/Specs/MatrixSpec.swift b/Example/Specs/MatrixSpec.swift index b66f547..87a658c 100644 --- a/Example/Specs/MatrixSpec.swift +++ b/Example/Specs/MatrixSpec.swift @@ -8,8 +8,8 @@ class MatrixSpec: QuickSpec { describe("matrix") { let m = float2x2(rows: [ - float2( 4, 3), - float2( 3, 2) + SIMD2( 4, 3), + SIMD2( 3, 2) ]) context("inverse") { @@ -18,8 +18,8 @@ class MatrixSpec: QuickSpec { it("should match expected") { // http://www.mathwords.com/i/inverse_of_a_matrix.htm let expectInvert = float2x2(rows: [ - float2( -2, 3), - float2( 3, -4) + SIMD2( -2, 3), + SIMD2( 3, -4) ]) expect(inverse) == expectInvert } @@ -42,7 +42,7 @@ class MatrixSpec: QuickSpec { // | 1 2 | // | | = 1*4-2*3 = -2 // | 3 4 | - expect(float2x2([float2(1, 2), float2(3, 4)]).determinant) == -2 + expect(float2x2([SIMD2(1, 2), SIMD2(3, 4)]).determinant) == -2 } it("should match math word 3x3 example") { diff --git a/Example/Specs/ProjectionSpec.swift b/Example/Specs/ProjectionSpec.swift index e2ef2d0..37627da 100644 --- a/Example/Specs/ProjectionSpec.swift +++ b/Example/Specs/ProjectionSpec.swift @@ -73,7 +73,7 @@ class ProjectionSpec: QuickSpec { var to: Perspective! beforeEach { - var points = Quadrilateral(CGRect(origin: CGPoint.zero, size: CGSize(width: 10, height: 10))).corners + let points = Quadrilateral(CGRect(origin: CGPoint.zero, size: CGSize(width: 10, height: 10))).corners from = Perspective(points) let turnedRight = [points[1], points[3], points[0], points[2]] to = Perspective(turnedRight) diff --git a/Example/Tests/PerspectiveTransformSpecHelper.swift b/Example/Tests/PerspectiveTransformSpecHelper.swift index fef1fe6..27f4716 100644 --- a/Example/Tests/PerspectiveTransformSpecHelper.swift +++ b/Example/Tests/PerspectiveTransformSpecHelper.swift @@ -111,7 +111,7 @@ enum TransformComponent: String { extension CALayer { func transformComponent(_ component: TransformComponent) -> Vector3 { var vector = Vector3() - let keyPathMap: [WritableKeyPath:String] = [ + let keyPathMap: [WritableKeyPath: String] = [ \.x: "x", \.y: "y", \.z: "z" diff --git a/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected@2x.png b/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected@2x.png deleted file mode 100644 index dd06a5e..0000000 Binary files a/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected@2x.png and /dev/null differ diff --git a/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected@3x.png b/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected@3x.png deleted file mode 100644 index ff08ae0..0000000 Binary files a/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected@3x.png and /dev/null differ diff --git a/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected_within_a_tolerance@2x.png b/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected_within_a_tolerance@2x.png new file mode 100644 index 0000000..6e6255d Binary files /dev/null and b/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected_within_a_tolerance@2x.png differ diff --git a/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected_within_a_tolerance@3x.png b/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected_within_a_tolerance@3x.png new file mode 100644 index 0000000..6fb5707 Binary files /dev/null and b/Example/Tests/ReferenceImages/SnapshotSpec/overlay_placement__in_perspective__should_look_as_expected_within_a_tolerance@3x.png differ diff --git a/Example/Tests/SnapshotSpec.swift b/Example/Tests/SnapshotSpec.swift index 4c5b847..c1799da 100644 --- a/Example/Tests/SnapshotSpec.swift +++ b/Example/Tests/SnapshotSpec.swift @@ -6,8 +6,6 @@ import Foundation class SnapshotSpec: QuickSpec { override func spec() { - let runningOnIphone5s = ProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] == "iPhone 5s" - describe("overlay placement") { var containerView: UIView! var overlayView: UIView! @@ -39,17 +37,14 @@ class SnapshotSpec: QuickSpec { overlayView.layer.transform = start.projectiveTransform(destination: destination) } - it("should look as expected") { - var tolerance: CGFloat = 0 + it("should look as expected within a tolerance") { + let tolerance: CGFloat = 0.02 let toleranceMessage = {"\(100 * tolerance)% tolerance"} - if runningOnIphone5s { - // For some unknown reason there is a 30% difference in image when running on Travis CI - // TODO: use pixel difference tolerance instead of image percent tolerance when it becomes available - // see https://github.com/uber/ios-snapshot-test-case/blob/master/CHANGELOG.md#502 - tolerance = 0.3 - fputs("images compared on iPhone 5s with \(toleranceMessage())\n".uppercased(), __stderrp) - } - expect(containerView).to(haveValidSnapshot(usesDrawRect: true, tolerance: tolerance), description: "should match with \(toleranceMessage())") + fputs("images are compared with \(toleranceMessage())\n".uppercased(), __stderrp) + expect(containerView).to(haveValidSnapshot(usesDrawRect: true, + pixelTolerance: tolerance, + tolerance: tolerance), + description: "should match with \(toleranceMessage())") } } } diff --git a/Gemfile.lock b/Gemfile.lock index d5ebdb0..8be17b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,29 +1,29 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.1) + CFPropertyList (3.0.2) activesupport (4.2.11.1) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.4.0) - algoliasearch (1.26.1) + algoliasearch (1.27.1) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) atomos (0.1.3) backports (3.15.0) claide (1.0.3) - cocoapods (1.8.0.beta.1) + cocoapods (1.8.4) activesupport (>= 4.0.2, < 5) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.8.0.beta.1) + cocoapods-core (= 1.8.4) cocoapods-deintegrate (>= 1.0.3, < 2.0) cocoapods-downloader (>= 1.2.2, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-stats (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.3.1, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) @@ -33,18 +33,19 @@ GEM nap (~> 1.0) ruby-macho (~> 1.4) xcodeproj (>= 1.11.1, < 2.0) - cocoapods-core (1.8.0.beta.1) + cocoapods-core (1.8.4) activesupport (>= 4.0.2, < 6) algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) fuzzy_match (~> 2.0.4) nap (~> 1.0) cocoapods-deintegrate (1.0.4) - cocoapods-downloader (1.2.2) + cocoapods-downloader (1.3.0) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.0) cocoapods-stats (1.1.0) - cocoapods-trunk (1.4.0) + cocoapods-trunk (1.4.1) nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.1.0) @@ -53,11 +54,11 @@ GEM escape (0.0.4) ethon (0.12.0) ffi (>= 1.3.0) - faraday (0.15.4) + faraday (0.17.3) multipart-post (>= 1.2, < 3) faraday_middleware (0.13.1) faraday (>= 0.7.4, < 1.0) - ffi (1.11.1) + ffi (1.11.3) fourflusher (2.3.1) fuzzy_match (2.0.4) gh (0.15.1) @@ -72,12 +73,12 @@ GEM httpclient (2.8.3) i18n (0.9.5) concurrent-ruby (~> 1.0) - json (2.2.0) + json (2.3.0) launchy (2.4.3) addressable (~> 2.3) - minitest (5.11.3) + minitest (5.13.0) molinillo (0.6.6) - multi_json (1.13.1) + multi_json (1.14.1) multipart-post (2.1.1) nanaimo (0.2.6) nap (1.1.0) @@ -101,10 +102,10 @@ GEM typhoeus (~> 0.6, >= 0.6.8) typhoeus (0.8.0) ethon (>= 0.8.0) - tzinfo (1.2.5) + tzinfo (1.2.6) thread_safe (~> 0.1) websocket (1.2.8) - xcodeproj (1.12.0) + xcodeproj (1.14.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) @@ -125,4 +126,4 @@ DEPENDENCIES xcpretty-travis-formatter BUNDLED WITH - 2.0.1 + 2.1.2 diff --git a/PerspectiveTransform.podspec b/PerspectiveTransform.podspec index c4df62e..d1676d0 100644 --- a/PerspectiveTransform.podspec +++ b/PerspectiveTransform.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| ts.requires_app_host = false ts.source_files = 'Example/Specs/**/*.{h,swift}', 'Example/Tests/*Helper.swift' ts.dependencies = { - 'Quick' => '~> 2.0', + 'Quick' => '~> 2.2', 'Nimble' => '~> 8.0' } end @@ -31,9 +31,8 @@ Pod::Spec.new do |s| ts.resources = 'Example/Tests/**/*.{png,jpg,svg}' ts.source_files = 'Example/Tests/**/*.{h,swift}', 'Example/PerspectiveTransform/resetAnchorPoint.swift' ts.dependencies = { - 'Quick' => '~> 2.0', - 'Nimble-Snapshots' => '~> 7.0', - 'iOSSnapshotTestCase' => '~> 6.0' + 'Quick' => '~> 2.2', + 'Nimble-Snapshots' => '~> 8.1' } end end diff --git a/Pod/Classes/Types.swift b/Pod/Classes/Types.swift index 598542f..7444b2a 100644 --- a/Pod/Classes/Types.swift +++ b/Pod/Classes/Types.swift @@ -9,6 +9,6 @@ import simd typealias Scalar = Double -typealias Vector3 = double3 +typealias Vector3 = SIMD3 typealias Matrix3x3 = double3x3 typealias Matrix4x4 = double4x4