summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLKeyboardPropertiesSpec.m
blob: c1c9410febebb768d223384752505c2980e8d733 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
//  SDLKeyboardPropertiesSpec.m
//  SmartDeviceLink


#import <Foundation/Foundation.h>

#import <Quick/Quick.h>
#import <Nimble/Nimble.h>

#import "SDLKeyboardLayout.h"
#import "SDLKeypressMode.h"
#import "SDLKeyboardProperties.h"
#import "SDLLanguage.h"
#import "SDLNames.h"


QuickSpecBegin(SDLKeyboardPropertiesSpec)

describe(@"Getter/Setter Tests", ^ {
    it(@"Should set and get correctly", ^ {
        SDLKeyboardProperties* testStruct = [[SDLKeyboardProperties alloc] init];
        
        testStruct.language = [SDLLanguage DA_DK];
        testStruct.keyboardLayout = [SDLKeyboardLayout QWERTZ];
        testStruct.keypressMode = [SDLKeypressMode RESEND_CURRENT_ENTRY];
        testStruct.limitedCharacterList = [@[@"s", @"r", @"f", @"q"] mutableCopy];
        testStruct.autoCompleteText = @"Auto Carrot";
        
        expect(testStruct.language).to(equal([SDLLanguage DA_DK]));
        expect(testStruct.keyboardLayout).to(equal([SDLKeyboardLayout QWERTZ]));
        expect(testStruct.keypressMode).to(equal([SDLKeypressMode RESEND_CURRENT_ENTRY]));
        expect(testStruct.limitedCharacterList).to(equal([@[@"s", @"r", @"f", @"q"] mutableCopy]));
        expect(testStruct.autoCompleteText).to(equal(@"Auto Carrot"));
    });
    
    it(@"Should get correctly when initialized", ^ {
        NSMutableDictionary* dict = [@{SDLNameLanguage:[SDLLanguage DA_DK],
                                       SDLNameKeyboardLayout:[SDLKeyboardLayout QWERTZ],
                                       SDLNameKeypressMode:[SDLKeypressMode RESEND_CURRENT_ENTRY],
                                       SDLNameLimitedCharacterList:[@[@"s", @"r", @"f", @"q"] mutableCopy],
                                       SDLNameAutoCompleteText:@"Auto Carrot"} mutableCopy];
        SDLKeyboardProperties* testStruct = [[SDLKeyboardProperties alloc] initWithDictionary:dict];
        
        expect(testStruct.language).to(equal([SDLLanguage DA_DK]));
        expect(testStruct.keyboardLayout).to(equal([SDLKeyboardLayout QWERTZ]));
        expect(testStruct.keypressMode).to(equal([SDLKeypressMode RESEND_CURRENT_ENTRY]));
        expect(testStruct.limitedCharacterList).to(equal([@[@"s", @"r", @"f", @"q"] mutableCopy]));
        expect(testStruct.autoCompleteText).to(equal(@"Auto Carrot"));
    });
    
    it(@"Should return nil if not set", ^ {
        SDLKeyboardProperties* testStruct = [[SDLKeyboardProperties alloc] init];
        
        expect(testStruct.language).to(beNil());
        expect(testStruct.keyboardLayout).to(beNil());
        expect(testStruct.keypressMode).to(beNil());
        expect(testStruct.limitedCharacterList).to(beNil());
        expect(testStruct.autoCompleteText).to(beNil());
    });
});

QuickSpecEnd