@@ -12,6 +12,7 @@ import KeyboardHelper
12
12
class KeyboardAppearanceInfoTests : XCTestCase {
13
13
14
14
var apperanceInfo : KeyboardAppearanceInfo !
15
+ var defaultsAppearanceInfo : KeyboardAppearanceInfo !
15
16
16
17
override func setUp( ) {
17
18
super. setUp ( )
@@ -24,41 +25,55 @@ class KeyboardAppearanceInfoTests: XCTestCase {
24
25
UIKeyboardAnimationCurveUserInfoKey: UIViewAnimationCurve . EaseOut. rawValue,
25
26
]
26
27
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
+
27
35
if #available( iOS 9 . 0 , * ) {
28
36
testUserInfo [ UIKeyboardIsLocalUserInfoKey] = false
37
+ defaultParsingUserInfo [ UIKeyboardIsLocalUserInfoKey] = " this shouldn't work "
29
38
} else {
30
39
print ( " UIKeyboardIsLocalUserInfoKey is not available before iOS9. " )
31
40
}
32
41
33
42
// Fake the notification
34
43
let note = NSNotification ( name: UIKeyboardWillShowNotification, object: nil , userInfo: testUserInfo)
35
44
apperanceInfo = KeyboardAppearanceInfo ( notification: note)
45
+ defaultsAppearanceInfo = KeyboardAppearanceInfo ( notification: NSNotification ( name: UIKeyboardWillShowNotification, object: nil , userInfo: defaultParsingUserInfo) )
36
46
}
37
47
38
48
func testBeginFrame( ) {
39
49
XCTAssertEqual ( apperanceInfo. beginFrame, CGRect ( x: 100 , y: 100 , width: 100 , height: 100 ) ,
40
50
" Parsing beginFrame from keyboard appearance info failed. " )
51
+ XCTAssertEqual ( defaultsAppearanceInfo. beginFrame, CGRectZero)
41
52
}
42
53
43
54
func testEndFrame( ) {
44
55
XCTAssertEqual ( apperanceInfo. endFrame, CGRect ( x: 200 , y: 200 , width: 200 , height: 200 ) ,
45
56
" Parsing endFrame from keyboard appearance info failed. " )
57
+ XCTAssertEqual ( defaultsAppearanceInfo. endFrame, CGRectZero)
46
58
}
47
59
48
60
@available ( iOS 9 . 0 , * )
49
61
func testBelongsToCurrentApp( ) {
50
62
XCTAssertEqual ( apperanceInfo. belongsToCurrentApp, false ,
51
63
" Parsing belongsToCurrentApp from keyboard appearance info failed. " )
64
+ XCTAssertEqual ( defaultsAppearanceInfo. belongsToCurrentApp, true )
52
65
}
53
66
54
67
func testAnimationDuration( ) {
55
68
XCTAssertEqual ( apperanceInfo. animationDuration, Double ( 3 ) ,
56
69
" Parsing animationDuration from keyboard appearance info failed. " )
70
+ XCTAssertEqual ( defaultsAppearanceInfo. animationDuration, 0.25 )
57
71
}
58
72
59
73
func testAnimationCurve( ) {
60
74
XCTAssertEqual ( apperanceInfo. animationCurve, UIViewAnimationCurve ( rawValue: 2 ) ,
61
75
" Parsing animationCurve from keyboard appearance info failed. " )
76
+ XCTAssertEqual ( defaultsAppearanceInfo. animationCurve, UIViewAnimationCurve . EaseInOut)
62
77
}
63
78
64
79
func testAnimateAlong( ) {
0 commit comments