Skip to content
This repository has been archived by the owner on Nov 21, 2017. It is now read-only.

Commit

Permalink
Add unit tests for TransitionTween.
Browse files Browse the repository at this point in the history
Reviewers: O4 Material Motion Apple platform reviewers, O2 Material Motion, markwei

Reviewed By: O4 Material Motion Apple platform reviewers, O2 Material Motion, markwei

Tags: #material_motion

Maniphest Tasks: T85

Differential Revision: http://codereview.cc/D1949
  • Loading branch information
Jeff Verkoeyen committed Nov 17, 2016
1 parent 944deab commit 85ef3ab
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/apps/Catalog/Catalog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
666FAA8B1D384A6B000363DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 666FAA8A1D384A6B000363DA /* Assets.xcassets */; };
666FAA8E1D384A6B000363DA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 666FAA8C1D384A6B000363DA /* LaunchScreen.storyboard */; };
66FB045A1DDD2C810083C6AD /* SlideInExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66FB04591DDD2C810083C6AD /* SlideInExample.swift */; };
66FB046B1DDD32CE0083C6AD /* TransitionTweenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66FB046A1DDD32CE0083C6AD /* TransitionTweenTests.swift */; };
8FF825A41AB30668A680C3AF /* Pods_MaterialMotionCoreAnimationTransitions_UnitTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C0D4766CE6EDE84E7D070B4 /* Pods_MaterialMotionCoreAnimationTransitions_UnitTests.framework */; };
A63FC3E99D8BC6FCE123E749 /* Pods_MaterialMotionCoreAnimationTransitions_Catalog.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4B80A5FA6B490C0A16775A4 /* Pods_MaterialMotionCoreAnimationTransitions_Catalog.framework */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -42,6 +43,7 @@
666FAA9A1D384A6B000363DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../UnitTests/Info.plist; sourceTree = "<group>"; };
666FAAA71D384D51000363DA /* UnitTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UnitTests-Bridging-Header.h"; path = "../UnitTests/UnitTests-Bridging-Header.h"; sourceTree = "<group>"; };
66FB04591DDD2C810083C6AD /* SlideInExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SlideInExample.swift; sourceTree = "<group>"; };
66FB046A1DDD32CE0083C6AD /* TransitionTweenTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransitionTweenTests.swift; sourceTree = "<group>"; };
76A7079425D84A1AF5463BE1 /* Pods-MaterialMotionCoreAnimationTransitions-Catalog.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MaterialMotionCoreAnimationTransitions-Catalog.debug.xcconfig"; path = "../../../Pods/Target Support Files/Pods-MaterialMotionCoreAnimationTransitions-Catalog/Pods-MaterialMotionCoreAnimationTransitions-Catalog.debug.xcconfig"; sourceTree = "<group>"; };
9255549872E19C856B2BF433 /* Pods-MaterialMotionCoreAnimationTransitions-UnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MaterialMotionCoreAnimationTransitions-UnitTests.release.xcconfig"; path = "../../../Pods/Target Support Files/Pods-MaterialMotionCoreAnimationTransitions-UnitTests/Pods-MaterialMotionCoreAnimationTransitions-UnitTests.release.xcconfig"; sourceTree = "<group>"; };
A4B80A5FA6B490C0A16775A4 /* Pods_MaterialMotionCoreAnimationTransitions_Catalog.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MaterialMotionCoreAnimationTransitions_Catalog.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -112,6 +114,7 @@
666FAA971D384A6B000363DA /* tests */ = {
isa = PBXGroup;
children = (
66FB046A1DDD32CE0083C6AD /* TransitionTweenTests.swift */,
);
name = tests;
path = ../../../tests/unit;
Expand Down Expand Up @@ -377,6 +380,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
66FB046B1DDD32CE0083C6AD /* TransitionTweenTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
70 changes: 70 additions & 0 deletions tests/unit/TransitionTweenTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright 2016-present The Material Motion Authors. All Rights Reserved.

Licensed 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 XCTest
import MaterialMotionTransitions
import MaterialMotionCoreAnimationTransitions

class TransitionTweenTests: XCTestCase {

var window: UIWindow! = nil

override func setUp() {
super.setUp()

window = UIWindow()
window.rootViewController = UIViewController()
window.rootViewController!.view.backgroundColor = .blue
window.makeKeyAndVisible()
window.layer.speed = 100
}

class TransitionTweenDirector: NSObject, TransitionDirector {
let transition: Transition
required init(transition: Transition) {
self.transition = transition
}

func setUp() {
let fadeIn = TransitionTween("opacity",
transition: transition,
segment: .init(position: 0, length: 1),
back: NSNumber(value: 0),
fore: NSNumber(value: 1))
transition.runtime.addPlan(fadeIn, to: transition.foreViewController.view.layer)
}
}

func testTransitionTweenTransitionDoesTerminate() {
let toPresent = UIViewController()
toPresent.view.backgroundColor = .red

toPresent.mdm_transitionController.directorClass = TransitionTweenDirector.self

let expect = expectation(description: "Did present")
window.rootViewController!.present(toPresent, animated: true) {
expect.fulfill()
}
waitForExpectations(timeout: 1)

let expectDismiss = expectation(description: "Did dismiss")
toPresent.dismiss(animated: true) {
expectDismiss.fulfill()
}
waitForExpectations(timeout: 1)
}

}

0 comments on commit 85ef3ab

Please sign in to comment.