summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLPerformInteractionSpec.m
blob: 7782b50dd328c2d0daa40b62589fff857482290b (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
//  SDLPerformInteractionSpec.m
//  SmartDeviceLink


#import <Foundation/Foundation.h>

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

#import "SDLInteractionMode.h"
#import "SDLLayoutMode.h"
#import "SDLPerformInteraction.h"
#import "SDLTTSChunk.h"
#import "SDLVrHelpItem.h"
#import "SDLNames.h"

QuickSpecBegin(SDLPerformInteractionSpec)

SDLTTSChunk* chunk1 = [[SDLTTSChunk alloc] init];
SDLTTSChunk* chunk2 = [[SDLTTSChunk alloc] init];
SDLTTSChunk* chunk3 = [[SDLTTSChunk alloc] init];
SDLVRHelpItem* helpItem = [[SDLVRHelpItem alloc] init];

describe(@"Getter/Setter Tests", ^ {
    it(@"Should set and get correctly", ^ {
        SDLPerformInteraction* testRequest = [[SDLPerformInteraction alloc] init];
        
        testRequest.initialText = @"a";
        testRequest.initialPrompt = [@[chunk1] mutableCopy];
        testRequest.interactionMode = [SDLInteractionMode VR_ONLY];
        testRequest.interactionChoiceSetIDList = [@[@1, @2, @3] mutableCopy];
        testRequest.helpPrompt = [@[chunk2] mutableCopy];
        testRequest.timeoutPrompt = [@[chunk3] mutableCopy];
        testRequest.timeout = @42000;
        testRequest.vrHelp = [@[helpItem] mutableCopy];
        testRequest.interactionLayout = [SDLLayoutMode ICON_WITH_SEARCH];
        
        expect(testRequest.initialText).to(equal(@"a"));
        expect(testRequest.initialPrompt).to(equal([@[chunk1] mutableCopy]));
        expect(testRequest.interactionMode).to(equal([SDLInteractionMode VR_ONLY]));
        expect(testRequest.interactionChoiceSetIDList).to(equal([@[@1, @2, @3] mutableCopy]));
        expect(testRequest.helpPrompt).to(equal([@[chunk2] mutableCopy]));
        expect(testRequest.timeoutPrompt).to(equal([@[chunk3] mutableCopy]));
        expect(testRequest.timeout).to(equal(@42000));
        expect(testRequest.vrHelp).to(equal([@[helpItem] mutableCopy]));
        expect(testRequest.interactionLayout).to(equal([SDLLayoutMode ICON_WITH_SEARCH]));
    });
    
    it(@"Should get correctly when initialized", ^ {
        NSMutableDictionary* dict = [@{SDLNameRequest:
                                           @{SDLNameParameters:
                                                 @{SDLNameInitialText:@"a",
                                                   SDLNameInitialPrompt:[@[chunk1] mutableCopy],
                                                   SDLNameInteractionMode:[SDLInteractionMode VR_ONLY],
                                                   SDLNameInteractionChoiceSetIdList:[@[@1, @2, @3] mutableCopy],
                                                   SDLNameHelpPrompt:[@[chunk2] mutableCopy],
                                                   SDLNameTimeoutPrompt:[@[chunk3] mutableCopy],
                                                   SDLNameTimeout:@42000,
                                                   SDLNameVRHelp:[@[helpItem] mutableCopy],
                                                   SDLNameInteractionLayout:[SDLLayoutMode ICON_WITH_SEARCH]},
                                             SDLNameOperationName:SDLNamePerformInteraction}} mutableCopy];
        SDLPerformInteraction* testRequest = [[SDLPerformInteraction alloc] initWithDictionary:dict];
        
        expect(testRequest.initialText).to(equal(@"a"));
        expect(testRequest.initialPrompt).to(equal([@[chunk1] mutableCopy]));
        expect(testRequest.interactionMode).to(equal([SDLInteractionMode VR_ONLY]));
        expect(testRequest.interactionChoiceSetIDList).to(equal([@[@1, @2, @3] mutableCopy]));
        expect(testRequest.helpPrompt).to(equal([@[chunk2] mutableCopy]));
        expect(testRequest.timeoutPrompt).to(equal([@[chunk3] mutableCopy]));
        expect(testRequest.timeout).to(equal(@42000));
        expect(testRequest.vrHelp).to(equal([@[helpItem] mutableCopy]));
        expect(testRequest.interactionLayout).to(equal([SDLLayoutMode ICON_WITH_SEARCH]));
    });
    
    it(@"Should return nil if not set", ^ {
        SDLPerformInteraction* testRequest = [[SDLPerformInteraction alloc] init];
        
        expect(testRequest.initialText).to(beNil());
        expect(testRequest.initialPrompt).to(beNil());
        expect(testRequest.interactionMode).to(beNil());
        expect(testRequest.interactionChoiceSetIDList).to(beNil());
        expect(testRequest.helpPrompt).to(beNil());
        expect(testRequest.timeoutPrompt).to(beNil());
        expect(testRequest.timeout).to(beNil());
        expect(testRequest.vrHelp).to(beNil());
        expect(testRequest.interactionLayout).to(beNil());
    });
});

QuickSpecEnd