Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Fix remaining warnings and fully pin to iOS 10 minimum OS. (#50)
Browse files Browse the repository at this point in the history
Also fixed a broken test on iOS 13 and 14.
  • Loading branch information
featherless authored Apr 5, 2021
1 parent d8c9ac3 commit 181a9ed
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 58 deletions.
2 changes: 1 addition & 1 deletion MotionInterchange.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Pod::Spec.new do |s|
s.license = "Apache 2.0"
s.homepage = "https://github.com/material-motion/motion-interchange-objc"
s.source = { :git => "https://github.com/material-motion/motion-interchange-objc.git", :tag => "v" + s.version.to_s }
s.platform = :ios, "9.0"
s.platform = :ios, "10.0"
s.requires_arc = true

s.public_header_files = "src/*.h"
Expand Down
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
workspace 'MotionInterchange.xcworkspace'
use_frameworks!
platform :ios, '10.0'

target "MotionInterchangeCatalog" do
pod 'CatalogByConvention'
Expand Down
10 changes: 5 additions & 5 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- CatalogByConvention (2.1.1)
- CatalogByConvention (2.5.2)
- MotionInterchange (4.0.0)

DEPENDENCIES:
Expand All @@ -15,9 +15,9 @@ EXTERNAL SOURCES:
:path: "./"

SPEC CHECKSUMS:
CatalogByConvention: c3a5319de04250a7cd4649127fcfca5fe3322a43
MotionInterchange: 61f6994d1fe915b931e8751e3f86098729580b6c
CatalogByConvention: ef713654160053be026fa4648dd28caf6b5ca4e1
MotionInterchange: cfe99ee1e149f20f86e9a8c4be17e2f0fbefda40

PODFILE CHECKSUM: 09090d12db5aab00a13fe82da94f338ebd03f5dc
PODFILE CHECKSUM: aea7b8b75a397821880e2ba54fc4cf979d21cd99

COCOAPODS: 1.9.3
COCOAPODS: 1.10.1
16 changes: 8 additions & 8 deletions tests/unit/CAMediaTimingFunctionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ class CAMediaTimingFunctionTests: XCTestCase {
func testReversalAlgorithm() {
let curve = CAMediaTimingFunction(controlPoints: 0.1, 0.2, 0.3, 0.4)
let reversed = curve.mdm_reversed()
XCTAssertEqualWithAccuracy(curve.mdm_point1.x, 1 - reversed.mdm_point2.x, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.mdm_point1.y, 1 - reversed.mdm_point2.y, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.mdm_point2.x, 1 - reversed.mdm_point1.x, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.mdm_point2.y, 1 - reversed.mdm_point1.y, accuracy: 0.001)
XCTAssertEqual(curve.mdm_point1.x, 1 - reversed.mdm_point2.x, accuracy: 0.001)
XCTAssertEqual(curve.mdm_point1.y, 1 - reversed.mdm_point2.y, accuracy: 0.001)
XCTAssertEqual(curve.mdm_point2.x, 1 - reversed.mdm_point1.x, accuracy: 0.001)
XCTAssertEqual(curve.mdm_point2.y, 1 - reversed.mdm_point1.y, accuracy: 0.001)
}

func testReversingBezierCurveTwiceGivesSameResult() {
let curve = CAMediaTimingFunction(controlPoints: 0.1, 0.2, 0.3, 0.4)
let reversed = curve.mdm_reversed()
let reversedAgain = reversed.mdm_reversed()
XCTAssertEqualWithAccuracy(curve.mdm_point1.x, reversedAgain.mdm_point1.x, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.mdm_point1.y, reversedAgain.mdm_point1.y, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.mdm_point2.x, reversedAgain.mdm_point2.x, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.mdm_point2.y, reversedAgain.mdm_point2.y, accuracy: 0.001)
XCTAssertEqual(curve.mdm_point1.x, reversedAgain.mdm_point1.x, accuracy: 0.001)
XCTAssertEqual(curve.mdm_point1.y, reversedAgain.mdm_point1.y, accuracy: 0.001)
XCTAssertEqual(curve.mdm_point2.x, reversedAgain.mdm_point2.x, accuracy: 0.001)
XCTAssertEqual(curve.mdm_point2.y, reversedAgain.mdm_point2.y, accuracy: 0.001)
}
}
14 changes: 7 additions & 7 deletions tests/unit/MDMLegacyAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ class MDMLegacyAPITests: XCTestCase {

let traits = MDMAnimationTraits(motionTiming: timing)

XCTAssertEqualWithAccuracy(traits.duration, timing.duration, accuracy: 0.001)
XCTAssertEqualWithAccuracy(traits.delay, timing.delay, accuracy: 0.001)
XCTAssertEqual(traits.duration, timing.duration, accuracy: 0.001)
XCTAssertEqual(traits.delay, timing.delay, accuracy: 0.001)
XCTAssertTrue(traits.timingCurve is CAMediaTimingFunction)
if let timingCurve = traits.timingCurve as? CAMediaTimingFunction {
XCTAssertEqualWithAccuracy(timingCurve.mdm_point1.x, timing.curve.data.0, accuracy: 0.001)
XCTAssertEqualWithAccuracy(timingCurve.mdm_point1.y, timing.curve.data.1, accuracy: 0.001)
XCTAssertEqualWithAccuracy(timingCurve.mdm_point2.x, timing.curve.data.2, accuracy: 0.001)
XCTAssertEqualWithAccuracy(timingCurve.mdm_point2.y, timing.curve.data.3, accuracy: 0.001)
XCTAssertEqual(timingCurve.mdm_point1.x, timing.curve.data.0, accuracy: 0.001)
XCTAssertEqual(timingCurve.mdm_point1.y, timing.curve.data.1, accuracy: 0.001)
XCTAssertEqual(timingCurve.mdm_point2.x, timing.curve.data.2, accuracy: 0.001)
XCTAssertEqual(timingCurve.mdm_point2.y, timing.curve.data.3, accuracy: 0.001)
}
XCTAssertTrue(traits.repetition is MDMRepetitionOverTime)
if let repetition = traits.repetition as? MDMRepetitionOverTime {
XCTAssertEqualWithAccuracy(repetition.duration, timing.repetition.amount, accuracy: 0.001)
XCTAssertEqual(repetition.duration, timing.repetition.amount, accuracy: 0.001)
XCTAssertEqual(repetition.autoreverses, timing.repetition.autoreverses.boolValue)
}
}
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/MDMModalMovementTimingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ - (void)viewDidLayoutSubviews {

// We just want the first position key path animation that affects this view controller.
if (!self.presentationPositionAnimation) {
self.presentationPositionAnimation = [self.view.layer animationForKey:@"position"];
UIView *iterator = self.view;
while (iterator != nil && self.presentationPositionAnimation == nil) {
self.presentationPositionAnimation = [iterator.layer animationForKey:@"position"];
iterator = iterator.superview;
}
}
}

Expand Down
40 changes: 20 additions & 20 deletions tests/unit/MDMMotionCurveTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,45 @@ class MDMMotionCurveTests: XCTestCase {

func testBezierCurveData() {
let curve = MotionCurveMakeBezier(p1x: 0.1, p1y: 0.2, p2x: 0.3, p2y: 0.4)
XCTAssertEqualWithAccuracy(curve.data.0, 0.1, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.1, 0.2, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.2, 0.3, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.3, 0.4, accuracy: 0.001)
XCTAssertEqual(curve.data.0, 0.1, accuracy: 0.001)
XCTAssertEqual(curve.data.1, 0.2, accuracy: 0.001)
XCTAssertEqual(curve.data.2, 0.3, accuracy: 0.001)
XCTAssertEqual(curve.data.3, 0.4, accuracy: 0.001)
}

func testBezierCurveFromTimingFunction() {
let timingFunction = CAMediaTimingFunction(controlPoints: 0.1, 0.2, 0.3, 0.4)
let curve = MotionCurve(fromTimingFunction: timingFunction)
XCTAssertEqualWithAccuracy(curve.data.0, 0.1, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.1, 0.2, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.2, 0.3, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.3, 0.4, accuracy: 0.001)
XCTAssertEqual(curve.data.0, 0.1, accuracy: 0.001)
XCTAssertEqual(curve.data.1, 0.2, accuracy: 0.001)
XCTAssertEqual(curve.data.2, 0.3, accuracy: 0.001)
XCTAssertEqual(curve.data.3, 0.4, accuracy: 0.001)
}

func testSpringCurveData() {
let curve = MotionCurveMakeSpring(mass: 0.1, tension: 0.2, friction: 0.3)
XCTAssertEqualWithAccuracy(curve.data.0, 0.1, accuracy: 0.001) // mass
XCTAssertEqualWithAccuracy(curve.data.1, 0.2, accuracy: 0.001) // tension
XCTAssertEqualWithAccuracy(curve.data.2, 0.3, accuracy: 0.001) // friction
XCTAssertEqualWithAccuracy(curve.data.3, 0.0, accuracy: 0.001)
XCTAssertEqual(curve.data.0, 0.1, accuracy: 0.001) // mass
XCTAssertEqual(curve.data.1, 0.2, accuracy: 0.001) // tension
XCTAssertEqual(curve.data.2, 0.3, accuracy: 0.001) // friction
XCTAssertEqual(curve.data.3, 0.0, accuracy: 0.001)
}

func testReversedBezierCurve() {
let curve = MotionCurveMakeBezier(p1x: 0.1, p1y: 0.2, p2x: 0.3, p2y: 0.4)
let reversed = MotionCurveReversedBezier(fromMotionCurve: curve)
XCTAssertEqualWithAccuracy(curve.data.0, 1 - reversed.data.2, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.1, 1 - reversed.data.3, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.2, 1 - reversed.data.0, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.3, 1 - reversed.data.1, accuracy: 0.001)
XCTAssertEqual(curve.data.0, 1 - reversed.data.2, accuracy: 0.001)
XCTAssertEqual(curve.data.1, 1 - reversed.data.3, accuracy: 0.001)
XCTAssertEqual(curve.data.2, 1 - reversed.data.0, accuracy: 0.001)
XCTAssertEqual(curve.data.3, 1 - reversed.data.1, accuracy: 0.001)
}

func testReversingBezierCurveTwiceGivesSameResult() {
let curve = MotionCurveMakeBezier(p1x: 0.1, p1y: 0.2, p2x: 0.3, p2y: 0.4)
let reversed = MotionCurveReversedBezier(fromMotionCurve: curve)
let reversedAgain = MotionCurveReversedBezier(fromMotionCurve: reversed)
XCTAssertEqualWithAccuracy(curve.data.0, reversedAgain.data.0, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.1, reversedAgain.data.1, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.2, reversedAgain.data.2, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.data.3, reversedAgain.data.3, accuracy: 0.001)
XCTAssertEqual(curve.data.0, reversedAgain.data.0, accuracy: 0.001)
XCTAssertEqual(curve.data.1, reversedAgain.data.1, accuracy: 0.001)
XCTAssertEqual(curve.data.2, reversedAgain.data.2, accuracy: 0.001)
XCTAssertEqual(curve.data.3, reversedAgain.data.3, accuracy: 0.001)
}
}
4 changes: 2 additions & 2 deletions tests/unit/MDMRepetitionOverTimeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class MDMRepetitionOverTimeTests: XCTestCase {

func testInitializationWithDuration() {
let repetition = MDMRepetitionOverTime(duration: 5.5)
XCTAssertEqualWithAccuracy(repetition.duration, 5.5, accuracy: 0.001)
XCTAssertEqual(repetition.duration, 5.5, accuracy: 0.001)
XCTAssertFalse(repetition.autoreverses)
}

func testInitializationWithDurationAndAutoreversed() {
let repetition = MDMRepetitionOverTime(duration: 5.5, autoreverses: true)
XCTAssertEqualWithAccuracy(repetition.duration, 5.5, accuracy: 0.001)
XCTAssertEqual(repetition.duration, 5.5, accuracy: 0.001)
XCTAssertTrue(repetition.autoreverses)
}
}
4 changes: 2 additions & 2 deletions tests/unit/MDMRepetitionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class MDMRepetitionTests: XCTestCase {

func testInitializationWithNumberOfRepetitions() {
let repetition = MDMRepetition(numberOfRepetitions: 5.5)
XCTAssertEqualWithAccuracy(repetition.numberOfRepetitions, 5.5, accuracy: 0.001)
XCTAssertEqual(repetition.numberOfRepetitions, 5.5, accuracy: 0.001)
XCTAssertFalse(repetition.autoreverses)
}

func testInitializationWithNumberOfRepetitionsAndAutoreversed() {
let repetition = MDMRepetition(numberOfRepetitions: 5.5, autoreverses: true)
XCTAssertEqualWithAccuracy(repetition.numberOfRepetitions, 5.5, accuracy: 0.001)
XCTAssertEqual(repetition.numberOfRepetitions, 5.5, accuracy: 0.001)
XCTAssertTrue(repetition.autoreverses)
}
}
24 changes: 12 additions & 12 deletions tests/unit/MDMSpringTimingCurve.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ class MDMTimingCurveTests: XCTestCase {

func testInitializerValuesWithNoInitialVelocity() {
let curve = MDMSpringTimingCurve(mass: 0.1, tension: 0.2, friction: 0.3)
XCTAssertEqualWithAccuracy(curve.mass, 0.1, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.tension, 0.2, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.friction, 0.3, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.initialVelocity, 0.0, accuracy: 0.001)
XCTAssertEqual(curve.mass, 0.1, accuracy: 0.001)
XCTAssertEqual(curve.tension, 0.2, accuracy: 0.001)
XCTAssertEqual(curve.friction, 0.3, accuracy: 0.001)
XCTAssertEqual(curve.initialVelocity, 0.0, accuracy: 0.001)
}

func testInitializerValuesWithInitialVelocity() {
let curve = MDMSpringTimingCurve(mass: 0.1, tension: 0.2, friction: 0.3, initialVelocity: 0.4)
XCTAssertEqualWithAccuracy(curve.mass, 0.1, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.tension, 0.2, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.friction, 0.3, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.initialVelocity, 0.4, accuracy: 0.001)
XCTAssertEqual(curve.mass, 0.1, accuracy: 0.001)
XCTAssertEqual(curve.tension, 0.2, accuracy: 0.001)
XCTAssertEqual(curve.friction, 0.3, accuracy: 0.001)
XCTAssertEqual(curve.initialVelocity, 0.4, accuracy: 0.001)
}

@available(iOS 9.0, *)
Expand All @@ -58,11 +58,11 @@ class MDMTimingCurveTests: XCTestCase {
let animation = view.layer.animation(forKey: animationKey) as? CASpringAnimation {

let curve = generator.springTimingCurve()
XCTAssertEqualWithAccuracy(curve.mass, animation.mass, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.tension, animation.stiffness, accuracy: 0.001)
XCTAssertEqualWithAccuracy(curve.friction, animation.damping, accuracy: 0.001)
XCTAssertEqual(curve.mass, animation.mass, accuracy: 0.001)
XCTAssertEqual(curve.tension, animation.stiffness, accuracy: 0.001)
XCTAssertEqual(curve.friction, animation.damping, accuracy: 0.001)
if animation.responds(to: #selector(initialVelocity)) {
XCTAssertEqualWithAccuracy(curve.initialVelocity, animation.initialVelocity, accuracy: 0.001)
XCTAssertEqual(curve.initialVelocity, animation.initialVelocity, accuracy: 0.001)
}
}
}
Expand Down

0 comments on commit 181a9ed

Please sign in to comment.