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

Commit 51b3ecb

Browse files
committed
tested for correct values in KeyboardAppearanceInfo
1 parent 5fed024 commit 51b3ecb

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

KeyboardHelperTests/Tests/KeyboardHelperTests.swift

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,28 @@ class KeyboardHelperTests: XCTestCase {
5757

5858
let expectation = expectationWithDescription("KeyboardHelper calls the delegate as the result of receiving the show notification")
5959
spyDelegate.expectation = expectation
60-
61-
NSNotificationCenter.defaultCenter().postNotificationName(UIKeyboardWillShowNotification, object: kh)
60+
61+
// NSNotificationCenter.defaultCenter().postNotificationName(UIKeyboardWillShowNotification, object: kh)
62+
let notification : NSNotification
63+
if #available(iOS 9.0, *) {
64+
notification = NSNotification(name: UIKeyboardWillShowNotification, object: kh, userInfo:[
65+
UIKeyboardAnimationCurveUserInfoKey : NSNumber(int: 7),
66+
UIKeyboardAnimationDurationUserInfoKey : NSNumber(double: 0.25),
67+
UIKeyboardFrameBeginUserInfoKey : NSValue(CGRect: CGRect(x: 0, y: 667, width: 375, height: 0)),
68+
UIKeyboardFrameEndUserInfoKey : NSValue(CGRect: CGRect(x: 0, y: 409, width: 375, height: 258)),
69+
UIKeyboardIsLocalUserInfoKey : NSNumber(bool: true)
70+
])
71+
} else {
72+
notification = NSNotification(name: UIKeyboardWillShowNotification, object: nil, userInfo:[
73+
UIKeyboardAnimationCurveUserInfoKey : NSNumber(int: 7),
74+
UIKeyboardAnimationDurationUserInfoKey : NSNumber(double: 0.25),
75+
UIKeyboardFrameBeginUserInfoKey : NSValue(CGRect: CGRect(x: 0, y: 667, width: 375, height: 0)),
76+
UIKeyboardFrameEndUserInfoKey : NSValue(CGRect: CGRect(x: 0, y: 409, width: 375, height: 258))
77+
])
78+
}
79+
80+
NSNotificationCenter.defaultCenter().postNotification(notification)
81+
6282

6383

6484
waitForExpectationsWithTimeout(1) { error in
@@ -70,8 +90,13 @@ class KeyboardHelperTests: XCTestCase {
7090
XCTFail("Expected delegate to be called")
7191
return
7292
}
73-
7493
XCTAssertNotNil(result)
94+
XCTAssertEqual(result.animationCurve, UIViewAnimationCurve(rawValue: 7))
95+
XCTAssertEqual(result.animationDuration, 0.25)
96+
XCTAssertEqual(result.beginFrame, CGRect(x: 0, y: 667, width: 375, height: 0))
97+
XCTAssertEqual(result.endFrame, CGRect(x: 0, y: 409, width: 375, height: 258))
98+
XCTAssertEqual(result.belongsToCurrentApp, true)
99+
75100
}
76101
}
77102

0 commit comments

Comments
 (0)