Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit f214583

Browse files
committed
tests for default values in parsing
1 parent 51b3ecb commit f214583

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

KeyboardHelperTests/Tests/KeyboardAppearanceInfoTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import KeyboardHelper
1212
class KeyboardAppearanceInfoTests: XCTestCase {
1313

1414
var apperanceInfo: KeyboardAppearanceInfo!
15+
var defaultsAppearanceInfo : KeyboardAppearanceInfo!
1516

1617
override func setUp() {
1718
super.setUp()
@@ -24,41 +25,55 @@ class KeyboardAppearanceInfoTests: XCTestCase {
2425
UIKeyboardAnimationCurveUserInfoKey: UIViewAnimationCurve.EaseOut.rawValue,
2526
]
2627

28+
var defaultParsingUserInfo: [String: AnyObject] = [
29+
UIKeyboardFrameBeginUserInfoKey: "bla",
30+
UIKeyboardFrameEndUserInfoKey: "bla",
31+
UIKeyboardAnimationDurationUserInfoKey: NSValue(CGRect: CGRect(x: 100, y: 100, width: 100, height: 100)),
32+
UIKeyboardAnimationCurveUserInfoKey: "bla",
33+
]
34+
2735
if #available(iOS 9.0, *) {
2836
testUserInfo[UIKeyboardIsLocalUserInfoKey] = false
37+
defaultParsingUserInfo[UIKeyboardIsLocalUserInfoKey] = "this shouldn't work"
2938
} else {
3039
print("UIKeyboardIsLocalUserInfoKey is not available before iOS9.")
3140
}
3241

3342
// Fake the notification
3443
let note = NSNotification(name: UIKeyboardWillShowNotification, object: nil, userInfo: testUserInfo)
3544
apperanceInfo = KeyboardAppearanceInfo(notification: note)
45+
defaultsAppearanceInfo = KeyboardAppearanceInfo(notification: NSNotification(name: UIKeyboardWillShowNotification, object: nil, userInfo: defaultParsingUserInfo))
3646
}
3747

3848
func testBeginFrame() {
3949
XCTAssertEqual(apperanceInfo.beginFrame, CGRect(x: 100, y: 100, width: 100, height: 100),
4050
"Parsing beginFrame from keyboard appearance info failed.")
51+
XCTAssertEqual(defaultsAppearanceInfo.beginFrame, CGRectZero)
4152
}
4253

4354
func testEndFrame() {
4455
XCTAssertEqual(apperanceInfo.endFrame, CGRect(x: 200, y: 200, width: 200, height: 200),
4556
"Parsing endFrame from keyboard appearance info failed.")
57+
XCTAssertEqual(defaultsAppearanceInfo.endFrame, CGRectZero)
4658
}
4759

4860
@available(iOS 9.0, *)
4961
func testBelongsToCurrentApp() {
5062
XCTAssertEqual(apperanceInfo.belongsToCurrentApp, false,
5163
"Parsing belongsToCurrentApp from keyboard appearance info failed.")
64+
XCTAssertEqual(defaultsAppearanceInfo.belongsToCurrentApp, true)
5265
}
5366

5467
func testAnimationDuration() {
5568
XCTAssertEqual(apperanceInfo.animationDuration, Double(3),
5669
"Parsing animationDuration from keyboard appearance info failed.")
70+
XCTAssertEqual(defaultsAppearanceInfo.animationDuration, 0.25)
5771
}
5872

5973
func testAnimationCurve() {
6074
XCTAssertEqual(apperanceInfo.animationCurve, UIViewAnimationCurve(rawValue: 2),
6175
"Parsing animationCurve from keyboard appearance info failed.")
76+
XCTAssertEqual(defaultsAppearanceInfo.animationCurve, UIViewAnimationCurve.EaseInOut)
6277
}
6378

6479
func testAnimateAlong() {

0 commit comments

Comments
 (0)