Skip to content

Commit

Permalink
Add tests for RotationDesignable
Browse files Browse the repository at this point in the history
  • Loading branch information
SD10 committed May 10, 2017
1 parent 08d2b86 commit 73e9d4f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions IBAnimatable.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
B0564B511EB046F600D1C5AB /* FillDesignableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0564B501EB046F600D1C5AB /* FillDesignableTests.swift */; };
B0564B531EB06BA500D1C5AB /* ColorTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0564B521EB06BA500D1C5AB /* ColorTypeTests.swift */; };
B062C7671E94D13B006C3CB8 /* SystemTransitionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B062C7661E94D13B006C3CB8 /* SystemTransitionAnimator.swift */; };
B08FAAEA1EB6B37700BA7BCC /* RotationDesignableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B08FAAE91EB6B37700BA7BCC /* RotationDesignableTests.swift */; };
C4275F7D1E9D59A6000C7F0B /* AnimatableTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4275F7C1E9D59A6000C7F0B /* AnimatableTabBarController.swift */; };
C47A737C1E86A9BD0044EFF8 /* SliderImagesDesignable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C47A737B1E86A9BD0044EFF8 /* SliderImagesDesignable.swift */; };
C4B4AD551E8645FD007A79A4 /* BackgroundImageDesignable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B4AD541E8645FD007A79A4 /* BackgroundImageDesignable.swift */; };
Expand Down Expand Up @@ -330,6 +331,7 @@
B0564B501EB046F600D1C5AB /* FillDesignableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FillDesignableTests.swift; sourceTree = "<group>"; };
B0564B521EB06BA500D1C5AB /* ColorTypeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorTypeTests.swift; sourceTree = "<group>"; };
B062C7661E94D13B006C3CB8 /* SystemTransitionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SystemTransitionAnimator.swift; sourceTree = "<group>"; };
B08FAAE91EB6B37700BA7BCC /* RotationDesignableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RotationDesignableTests.swift; sourceTree = "<group>"; };
C4275F7C1E9D59A6000C7F0B /* AnimatableTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatableTabBarController.swift; sourceTree = "<group>"; };
C47A737B1E86A9BD0044EFF8 /* SliderImagesDesignable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SliderImagesDesignable.swift; sourceTree = "<group>"; };
C4B4AD541E8645FD007A79A4 /* BackgroundImageDesignable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundImageDesignable.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -793,6 +795,7 @@
children = (
B0564B4E1EB01AD000D1C5AB /* CornerDesignableTests.swift */,
B0564B501EB046F600D1C5AB /* FillDesignableTests.swift */,
B08FAAE91EB6B37700BA7BCC /* RotationDesignableTests.swift */,
B0564B471EB01A8100D1C5AB /* Info.plist */,
B0564B521EB06BA500D1C5AB /* ColorTypeTests.swift */,
);
Expand Down Expand Up @@ -1283,6 +1286,7 @@
buildActionMask = 2147483647;
files = (
B0564B531EB06BA500D1C5AB /* ColorTypeTests.swift in Sources */,
B08FAAEA1EB6B37700BA7BCC /* RotationDesignableTests.swift in Sources */,
B0564B511EB046F600D1C5AB /* FillDesignableTests.swift in Sources */,
B0564B4F1EB01AD000D1C5AB /* CornerDesignableTests.swift in Sources */,
);
Expand Down
57 changes: 57 additions & 0 deletions IBAnimatableTests/RotationDesignableTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// RotationDesignableTests.swift
// IBAnimatable
//
// Created by Steven on 4/30/17.
// Copyright © 2017 IBAnimatable. All rights reserved.
//

import XCTest
@testable import IBAnimatable

final class RotationDesignableTests: XCTestCase {

override func setUp() {
super.setUp()
}

override func tearDown() {
super.tearDown()
}

func testRotate() {
helper_testRotate(element: AnimatableView())
helper_testRotate(element: AnimatableScrollView())
helper_testRotate(element: AnimatableImageView())
helper_testRotate(element: AnimatableStackView())
helper_testRotate(element: AnimatableLabel())
helper_testRotate(element: AnimatableSlider())
}

private func helper_testRotate(element: MockRotationDesignable) {
element.rotate = -360
XCTAssertEqual(element.transform, .identity)
element.rotate = 360
XCTAssertEqual(element.transform, .identity)
element.rotate = 90
let mockTransform = CGAffineTransform(rotationAngle: .pi * 90 / 180)
XCTAssertEqual(element.transform, mockTransform)
}
}

// MARK: - MockRotationDesignable

protocol MockRotationDesignable: class, RotationDesignable {

var transform: CGAffineTransform { get set }

}

// MARK: - Classes with RotationDesignable conformance

extension AnimatableView: MockRotationDesignable {}
extension AnimatableScrollView: MockRotationDesignable {}
extension AnimatableImageView: MockRotationDesignable {}
extension AnimatableStackView: MockRotationDesignable {}
extension AnimatableLabel: MockRotationDesignable {}
extension AnimatableSlider: MockRotationDesignable {}

0 comments on commit 73e9d4f

Please sign in to comment.