@@ -57,8 +57,28 @@ class KeyboardHelperTests: XCTestCase {
57
57
58
58
let expectation = expectationWithDescription ( " KeyboardHelper calls the delegate as the result of receiving the show notification " )
59
59
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
+
62
82
63
83
64
84
waitForExpectationsWithTimeout ( 1 ) { error in
@@ -70,8 +90,13 @@ class KeyboardHelperTests: XCTestCase {
70
90
XCTFail ( " Expected delegate to be called " )
71
91
return
72
92
}
73
-
74
93
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
+
75
100
}
76
101
}
77
102
0 commit comments