-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |