summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/DevAPISpecs/SDLConfigurationSpec.m
blob: 38fb36ec95cf062bc142c9984680209546ccd317 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#import <Quick/Quick.h>
#import <Nimble/Nimble.h>

#import "SDLConfiguration.h"
#import "SDLFileManagerConfiguration.h"
#import "SDLLifecycleConfiguration.h"
#import "SDLLogConfiguration.h"
#import "SDLLockScreenConfiguration.h"
#import "SDLStreamingMediaConfiguration.h"
#import "SDLEncryptionConfiguration.h"

QuickSpecBegin(SDLConfigurationSpec)

describe(@"a configuration", ^{
    __block SDLConfiguration *testConfig = nil;

    context(@"created with custom configs", ^{
        __block SDLLifecycleConfiguration *someLifecycleConfig = nil;
        __block SDLLockScreenConfiguration *someLockscreenConfig = nil;
        __block SDLLogConfiguration *someLogConfig = nil;
        __block SDLStreamingMediaConfiguration *someStreamingConfig = nil;
        __block SDLFileManagerConfiguration *someFileManagerConfig = nil;
        __block SDLEncryptionConfiguration *someEncryptionConfig = nil;

        __block NSString *someAppName = nil;
        __block NSString *someAppId = nil;
        __block UIColor *someBackgroundColor = nil;
        __block UIImage *someImage = nil;
        
        beforeEach(^{
            someAppName = @"some name";
            someAppId = @"some id";
            someBackgroundColor = [UIColor blueColor];
            someImage = [UIImage imageNamed:@"testImagePNG" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
            
            someLifecycleConfig = [SDLLifecycleConfiguration defaultConfigurationWithAppName:someAppName fullAppId:someAppId];
            someLockscreenConfig = [SDLLockScreenConfiguration enabledConfigurationWithAppIcon:someImage backgroundColor:someBackgroundColor];
            someLogConfig = [SDLLogConfiguration defaultConfiguration];
            someStreamingConfig  = [SDLStreamingMediaConfiguration insecureConfiguration];
            someFileManagerConfig = [SDLFileManagerConfiguration defaultConfiguration];
            someEncryptionConfig = [SDLEncryptionConfiguration defaultConfiguration];
        });

        it(@"initWithLifecycle:lockScreen:logging:", ^{
            #pragma clang diagnostic push
            #pragma clang diagnostic ignored "-Wdeprecated-declarations"
            testConfig = [[SDLConfiguration alloc] initWithLifecycle:someLifecycleConfig lockScreen:someLockscreenConfig logging:someLogConfig];

            expect(testConfig.lifecycleConfig).to(equal(someLifecycleConfig));
            expect(testConfig.lockScreenConfig).to(equal(someLockscreenConfig));
            expect(testConfig.loggingConfig).to(equal(someLogConfig));
            expect(testConfig.streamingMediaConfig).to(beNil());
            expect(testConfig.fileManagerConfig).toNot(beNil());
            #pragma clang diagnostic pop
        });

        it(@"initWithLifecycle:lockScreen:logging:fileManager:", ^{
            testConfig = [[SDLConfiguration alloc] initWithLifecycle:someLifecycleConfig lockScreen:someLockscreenConfig logging:someLogConfig fileManager:someFileManagerConfig encryption: someEncryptionConfig];

            expect(testConfig.lifecycleConfig).to(equal(someLifecycleConfig));
            expect(testConfig.lockScreenConfig).to(equal(someLockscreenConfig));
            expect(testConfig.loggingConfig).to(equal(someLogConfig));
            expect(testConfig.streamingMediaConfig).to(beNil());
            expect(testConfig.fileManagerConfig).to(equal(someFileManagerConfig));
            expect(testConfig.encryptionConfig).to(equal(someEncryptionConfig));
        });

        it(@"configurationWithLifecycle:lockScreen:logging:", ^{
            #pragma clang diagnostic push
            #pragma clang diagnostic ignored "-Wdeprecated-declarations"
            testConfig = [SDLConfiguration configurationWithLifecycle:someLifecycleConfig lockScreen:someLockscreenConfig logging:someLogConfig];

            expect(testConfig.lifecycleConfig).to(equal(someLifecycleConfig));
            expect(testConfig.lockScreenConfig).to(equal(someLockscreenConfig));
            expect(testConfig.loggingConfig).to(equal(someLogConfig));
            expect(testConfig.streamingMediaConfig).to(beNil());
            expect(testConfig.fileManagerConfig).toNot(beNil());
            #pragma clang diagnostic pop
        });

        it(@"configurationWithLifecycle:lockScreen:logging:fileManager", ^{
            testConfig = [SDLConfiguration configurationWithLifecycle:someLifecycleConfig lockScreen:someLockscreenConfig logging:someLogConfig fileManager:someFileManagerConfig];

            expect(testConfig.lifecycleConfig).to(equal(someLifecycleConfig));
            expect(testConfig.lockScreenConfig).to(equal(someLockscreenConfig));
            expect(testConfig.loggingConfig).to(equal(someLogConfig));
            expect(testConfig.streamingMediaConfig).to(beNil());
            expect(testConfig.fileManagerConfig).to(equal(someFileManagerConfig));
        });

        describe(@"streaming media config", ^{
            beforeEach(^{
                someLifecycleConfig = [SDLLifecycleConfiguration defaultConfigurationWithAppName:someAppName fullAppId:someAppId];
                someLifecycleConfig.appType = SDLAppHMITypeNavigation;
            });

            it(@"initWithLifecycle:lockScreen:logging:streamingMedia:", ^{
                #pragma clang diagnostic push
                #pragma clang diagnostic ignored "-Wdeprecated-declarations"
                testConfig = [[SDLConfiguration alloc] initWithLifecycle:someLifecycleConfig lockScreen:someLockscreenConfig logging:someLogConfig streamingMedia:someStreamingConfig];

                expect(testConfig.lifecycleConfig).to(equal(someLifecycleConfig));
                expect(testConfig.lockScreenConfig).to(equal(someLockscreenConfig));
                expect(testConfig.loggingConfig).to(equal(someLogConfig));
                expect(testConfig.streamingMediaConfig).to(equal(someStreamingConfig));
                expect(testConfig.fileManagerConfig).toNot(beNil());
                #pragma clang diagnostic pop
            });

            it(@"initWithLifecycle:lockScreen:logging:streamingMedia:fileManager:", ^{
                testConfig = [[SDLConfiguration alloc] initWithLifecycle:someLifecycleConfig lockScreen:someLockscreenConfig logging:someLogConfig streamingMedia:someStreamingConfig fileManager:someFileManagerConfig encryption:[SDLEncryptionConfiguration defaultConfiguration]];

                expect(testConfig.lifecycleConfig).to(equal(someLifecycleConfig));
                expect(testConfig.lockScreenConfig).to(equal(someLockscreenConfig));
                expect(testConfig.loggingConfig).to(equal(someLogConfig));
                expect(testConfig.streamingMediaConfig).to(equal(someStreamingConfig));
                expect(testConfig.fileManagerConfig).to(equal(someFileManagerConfig));
            });

            it(@"configurationWithLifecycle:lockScreen:logging:streamingMedia:", ^{
                #pragma clang diagnostic push
                #pragma clang diagnostic ignored "-Wdeprecated-declarations"
                testConfig = [SDLConfiguration configurationWithLifecycle:someLifecycleConfig lockScreen:someLockscreenConfig logging:someLogConfig streamingMedia:someStreamingConfig];

                expect(testConfig.lifecycleConfig).to(equal(someLifecycleConfig));
                expect(testConfig.lockScreenConfig).to(equal(someLockscreenConfig));
                expect(testConfig.loggingConfig).to(equal(someLogConfig));
                expect(testConfig.streamingMediaConfig).to(equal(someStreamingConfig));
                expect(testConfig.fileManagerConfig).toNot(beNil());
                #pragma clang diagnostic pop
            });

            it(@"configurationWithLifecycle:lockScreen:logging:streamingMedia:fileManager:", ^{
                testConfig = [SDLConfiguration configurationWithLifecycle:someLifecycleConfig lockScreen:someLockscreenConfig logging:someLogConfig streamingMedia:someStreamingConfig fileManager:someFileManagerConfig];

                expect(testConfig.lifecycleConfig).to(equal(someLifecycleConfig));
                expect(testConfig.lockScreenConfig).to(equal(someLockscreenConfig));
                expect(testConfig.loggingConfig).to(equal(someLogConfig));
                expect(testConfig.streamingMediaConfig).to(equal(someStreamingConfig));
                expect(testConfig.fileManagerConfig).to(equal(someFileManagerConfig));
            });
        });
    });
});

QuickSpecEnd