summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m
blob: 004ee66abbe7988fe9653dd2cb744eb7ec3e5789 (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
//
//  SDLTextAndGraphicUpdateOperationSpec.m
//  SmartDeviceLinkTests
//
//  Created by Joel Fischer on 8/18/20.
//  Copyright © 2020 smartdevicelink. All rights reserved.
//

#import <Foundation/Foundation.h>

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

#import "SDLFileManager.h"
#import "SDLGlobals.h"
#import "SDLImage.h"
#import "SDLImageField.h"
#import "SDLImageField+ScreenManagerExtensions.h"
#import "SDLMetadataTags.h"
#import "SDLResult.h"
#import "SDLSetDisplayLayout.h"
#import "SDLSetDisplayLayoutResponse.h"
#import "SDLShow.h"
#import "SDLShowResponse.h"
#import "SDLTemplateConfiguration.h"
#import "SDLTextAndGraphicState.h"
#import "SDLTextAndGraphicUpdateOperation.h"
#import "SDLTextField.h"
#import "SDLTextField+ScreenManagerExtensions.h"
#import "SDLTextFieldName.h"
#import "SDLVersion.h"
#import "SDLWindowCapability.h"
#import "TestConnectionManager.h"

QuickSpecBegin(SDLTextAndGraphicUpdateOperationSpec)

SDLTextField *fieldLine1 = [[SDLTextField alloc] initWithName:SDLTextFieldNameMainField1 characterSet:SDLCharacterSetUtf8 width:20 rows:20];
SDLTextField *fieldLine2 = [[SDLTextField alloc] initWithName:SDLTextFieldNameMainField2 characterSet:SDLCharacterSetUtf8 width:20 rows:20];
SDLTextField *fieldLine3 = [[SDLTextField alloc] initWithName:SDLTextFieldNameMainField3 characterSet:SDLCharacterSetUtf8 width:20 rows:20];
SDLTextField *fieldLine4 = [[SDLTextField alloc] initWithName:SDLTextFieldNameMainField4 characterSet:SDLCharacterSetUtf8 width:20 rows:20];
SDLImageField *fieldGraphic = [[SDLImageField alloc] initWithName:SDLImageFieldNameGraphic imageTypeSupported:@[SDLFileTypePNG] imageResolution:nil];
SDLImageField *fieldSecondaryGraphic = [[SDLImageField alloc] initWithName:SDLImageFieldNameSecondaryGraphic imageTypeSupported:@[SDLFileTypePNG] imageResolution:nil];

NSString *field1String = @"Text Field 1";
NSString *field2String = @"Text Field 2";
NSString *field3String = @"Text Field 3";
NSString *field4String = @"Text Field 4";
NSString *titleString = @"Title";
NSString *mediaTrackString = @"Media track string";

NSString *testArtworkName = @"some artwork name";
SDLArtwork *testArtwork = [[SDLArtwork alloc] initWithData:[@"Test data" dataUsingEncoding:NSUTF8StringEncoding] name:testArtworkName fileExtension:@"png" persistent:NO];
NSString *testArtworkName2 = @"some other artwork name";
SDLArtwork *testArtwork2 = [[SDLArtwork alloc] initWithData:[@"Test data 2" dataUsingEncoding:NSUTF8StringEncoding] name:testArtworkName2 fileExtension:@"png" persistent:NO];
SDLArtwork *testStaticIcon = [SDLArtwork artworkWithStaticIcon:SDLStaticIconNameDate];

SDLTemplateConfiguration *newConfiguration = [[SDLTemplateConfiguration alloc] initWithPredefinedLayout:SDLPredefinedLayoutTilesOnly];

describe(@"the text and graphic operation", ^{
    __block SDLTextAndGraphicUpdateOperation *testOp = nil;

    __block TestConnectionManager *testConnectionManager = nil;
    __block SDLFileManager *mockFileManager = nil;
    __block SDLWindowCapability *windowCapability = nil;
    __block SDLTextAndGraphicState *updatedState = nil;
    __block SDLWindowCapability *allEnabledCapability = [[SDLWindowCapability alloc] init];

    __block SDLShowResponse *successShowResponse = [[SDLShowResponse alloc] init];
    __block SDLShowResponse *failShowResponse = [[SDLShowResponse alloc] init];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    __block SDLSetDisplayLayoutResponse *successSetDisplayLayoutResponse = [[SDLSetDisplayLayoutResponse alloc] init];
    __block SDLSetDisplayLayoutResponse *failSetDisplayLayoutResponse = [[SDLSetDisplayLayoutResponse alloc] init];
#pragma clang diagnostic pop
    __block SDLTextAndGraphicState *emptyCurrentData = nil;

    __block SDLTextAndGraphicState *receivedState = nil;
    __block NSError *receivedError = nil;
    __block NSError *completionError = nil;

    beforeEach(^{
        testConnectionManager = [[TestConnectionManager alloc] init];
        mockFileManager = OCMClassMock([SDLFileManager class]);
        testOp = nil;
        updatedState = nil;
        allEnabledCapability.imageFields = [SDLImageField allImageFields];
        allEnabledCapability.textFields = [SDLTextField allTextFields];

        successShowResponse.success = @YES;
        successShowResponse.resultCode = SDLResultSuccess;
        successSetDisplayLayoutResponse.success = @YES;
        successSetDisplayLayoutResponse.resultCode = SDLResultSuccess;
        failShowResponse.success = @NO;
        failShowResponse.resultCode = SDLResultInUse;
        failSetDisplayLayoutResponse.success = @NO;
        failSetDisplayLayoutResponse.resultCode = SDLResultInUse;

        emptyCurrentData = [[SDLTextAndGraphicState alloc] init];
        receivedState = nil;
        receivedError = nil;

        // Default to the max version
        [SDLGlobals sharedGlobals].rpcVersion = [SDLVersion versionWithString:SDLMaxProxyRPCVersion];
    });

    // updating text fields
    describe(@"updating text fields", ^{
        // with textfields available == nil
        context(@"with textfields available == nil", ^{
            beforeEach(^{
                windowCapability = [[SDLWindowCapability alloc] init];
            });

            context(@"when sending four lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;
                    updatedState.textField3 = field3String;
                    updatedState.textField4 = field4String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should not send any text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(beEmpty());
                    expect(sentShow.mainField2).to(beEmpty());
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beNil());
                    expect(sentShow.metadataTags.mainField2).to(beNil());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });
        });

        // when updating the media track and title
        context(@"when updating the media track and title", ^{
            beforeEach(^{
                updatedState = [[SDLTextAndGraphicState alloc] init];
                updatedState.title = titleString;
                updatedState.mediaTrackTextField = mediaTrackString;
            });

            // when they're available
            context(@"when they're available", ^{
                beforeEach(^{
                    windowCapability = [[SDLWindowCapability alloc] init];
                    windowCapability.textFields = [SDLTextField allTextFields];
                });

                it(@"should send the media track and title", ^{
                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;
                    expect(sentShow.templateTitle).toNot(beNil());
                    expect(sentShow.mediaTrack).toNot(beNil());
                });
            });

            // when they're not available
            context(@"when they're not available", ^{
                beforeEach(^{
                    windowCapability = [[SDLWindowCapability alloc] init];
                });

                it(@"should not send the media track and title", ^{
                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.mediaTrack).to(beEmpty());
                });
            });
        });

        // with one line available
        context(@"with one line available", ^{
            beforeEach(^{
                windowCapability = [[SDLWindowCapability alloc] init];
                windowCapability.textFields = @[fieldLine1];
            });

            context(@"when sending one line of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should only send one line of text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal(field1String));
                    expect(sentShow.mainField2).to(beEmpty());
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beNil());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending two lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should concatenate the strings into one line", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@ - %@", field1String, field2String]));
                    expect(sentShow.mainField2).to(beEmpty());
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beNil());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending three lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;
                    updatedState.textField3 = field3String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should concatenate the strings into one line", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@ - %@ - %@", field1String, field2String, field3String]));
                    expect(sentShow.mainField2).to(beEmpty());
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beNil());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending four lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;
                    updatedState.textField3 = field3String;
                    updatedState.textField4 = field4String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should concatenate the strings into one line", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@ - %@ - %@ - %@", field1String, field2String, field3String, field4String]));
                    expect(sentShow.mainField2).to(beEmpty());
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beNil());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });
        });

        // with two lines available
        context(@"with two lines available", ^{
            beforeEach(^{
                windowCapability = [[SDLWindowCapability alloc] init];
                windowCapability.textFields = @[fieldLine1, fieldLine2];
            });

            context(@"when sending one line of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should only send one line of text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal(field1String));
                    expect(sentShow.mainField2).to(beEmpty());
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beNil());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending two lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should send two lines of text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal(field1String));
                    expect(sentShow.mainField2).to(equal(field2String));
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beEmpty());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending three lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;
                    updatedState.textField3 = field3String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should concatenate the strings into two lines", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@ - %@", field1String, field2String]));
                    expect(sentShow.mainField2).to(equal(field3String));
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beEmpty());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending four lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;
                    updatedState.textField3 = field3String;
                    updatedState.textField4 = field4String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should concatenate the strings into two lines", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@ - %@", field1String, field2String]));
                    expect(sentShow.mainField2).to(equal([NSString stringWithFormat:@"%@ - %@", field3String, field4String]));
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beEmpty());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });
        });

        // with three lines available
        context(@"with three lines available", ^{
            beforeEach(^{
                windowCapability = [[SDLWindowCapability alloc] init];
                windowCapability.textFields = @[fieldLine1, fieldLine2, fieldLine3];
            });

            context(@"when sending one line of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should only send one line of text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@", field1String]));
                    expect(sentShow.mainField2).to(beEmpty());
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beNil());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending two lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should send two lines of text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@", field1String]));
                    expect(sentShow.mainField2).to(equal([NSString stringWithFormat:@"%@", field2String]));
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beEmpty());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending three lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;
                    updatedState.textField3 = field3String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should send three lines of text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@", field1String]));
                    expect(sentShow.mainField2).to(equal([NSString stringWithFormat:@"%@", field2String]));
                    expect(sentShow.mainField3).to(equal([NSString stringWithFormat:@"%@", field3String]));
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beEmpty());
                    expect(sentShow.metadataTags.mainField3).to(beEmpty());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending four lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;
                    updatedState.textField3 = field3String;
                    updatedState.textField4 = field4String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should concatenate the strings into three lines", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@", field1String]));
                    expect(sentShow.mainField2).to(equal([NSString stringWithFormat:@"%@", field2String]));
                    expect(sentShow.mainField3).to(equal([NSString stringWithFormat:@"%@ - %@", field3String, field4String]));
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beEmpty());
                    expect(sentShow.metadataTags.mainField3).to(beEmpty());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });
        });

        // with four lines available
        context(@"with four lines available", ^{
            beforeEach(^{
                windowCapability = [[SDLWindowCapability alloc] init];
                windowCapability.textFields = @[fieldLine1, fieldLine2, fieldLine3, fieldLine4];
            });

            context(@"when sending one line of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should only send one line of text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@", field1String]));
                    expect(sentShow.mainField2).to(beEmpty());
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beNil());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending two lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should send two lines of text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@", field1String]));
                    expect(sentShow.mainField2).to(equal([NSString stringWithFormat:@"%@", field2String]));
                    expect(sentShow.mainField3).to(beEmpty());
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beEmpty());
                    expect(sentShow.metadataTags.mainField3).to(beNil());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending three lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;
                    updatedState.textField3 = field3String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should send three lines text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@", field1String]));
                    expect(sentShow.mainField2).to(equal([NSString stringWithFormat:@"%@", field2String]));
                    expect(sentShow.mainField3).to(equal([NSString stringWithFormat:@"%@", field3String]));
                    expect(sentShow.mainField4).to(beEmpty());
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beEmpty());
                    expect(sentShow.metadataTags.mainField3).to(beEmpty());
                    expect(sentShow.metadataTags.mainField4).to(beNil());
                });
            });

            context(@"when sending four lines of text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.textField2 = field2String;
                    updatedState.textField3 = field3String;
                    updatedState.textField4 = field4String;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                });

                it(@"should send four lines of text", ^{
                    SDLShow *sentShow = testConnectionManager.receivedRequests.firstObject;

                    expect(testOp.isFinished).to(beTrue());
                    expect(sentShow.mainField1).to(equal([NSString stringWithFormat:@"%@", field1String]));
                    expect(sentShow.mainField2).to(equal([NSString stringWithFormat:@"%@", field2String]));
                    expect(sentShow.mainField3).to(equal([NSString stringWithFormat:@"%@", field3String]));
                    expect(sentShow.mainField4).to(equal([NSString stringWithFormat:@"%@", field4String]));
                    expect(sentShow.templateTitle).to(beEmpty());
                    expect(sentShow.alignment).to(beNil());
                    expect(sentShow.mediaTrack).to(beEmpty());
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                    expect(sentShow.metadataTags.mainField1).to(beEmpty());
                    expect(sentShow.metadataTags.mainField2).to(beEmpty());
                    expect(sentShow.metadataTags.mainField3).to(beEmpty());
                    expect(sentShow.metadataTags.mainField4).to(beEmpty());
                });
            });
        });

        // should call the update handler when done
        context(@"should call the update handler when done", ^{
            __block BOOL didCallHandler = NO;
            beforeEach(^{
                windowCapability = [[SDLWindowCapability alloc] init];
                windowCapability.textFields = @[fieldLine1, fieldLine2, fieldLine3, fieldLine4];

                updatedState = [[SDLTextAndGraphicState alloc] init];
                updatedState.textField1 = field1String;
                updatedState.textField2 = field2String;
                updatedState.textField3 = field3String;
                updatedState.textField4 = field4String;

                testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:^(NSError * _Nullable error) {
                    didCallHandler = YES;
                }];
                [testOp start];

                [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
            });

            it(@"should send the text and then call the update handler", ^{
                expect(didCallHandler).to(equal(YES));
            });
        });

        // should call the currentScreenDataUpdatedHandler when the screen data is updated
        context(@"should call the currentScreenDataUpdatedHandler when the screen data is updated", ^{
            __block SDLTextAndGraphicState *updatedData = nil;
            beforeEach(^{
                windowCapability = [[SDLWindowCapability alloc] init];
                windowCapability.textFields = @[fieldLine1, fieldLine2, fieldLine3, fieldLine4];

                updatedState = [[SDLTextAndGraphicState alloc] init];
                updatedState.textField1 = field1String;
                updatedState.textField2 = field2String;
                updatedState.textField3 = field3String;
                updatedState.textField4 = field4String;

                testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState *_Nullable newScreenData, NSError *_Nullable error) {
                    updatedData = newScreenData;
                } updateCompletionHandler:nil];
                [testOp start];

                [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
            });

            it(@"should send the text and then call the update handler", ^{
                expect(updatedData.textField1).to(equal(field1String));
                expect(updatedData.textField2).to(equal(field2String));
                expect(updatedData.textField3).to(equal(field3String));
                expect(updatedData.textField4).to(equal(field4String));
            });
        });
    });

    // updating with error state
    describe(@"updating with error state", ^{
        beforeEach(^{
            updatedState = [[SDLTextAndGraphicState alloc] init];
            updatedState.textField1 = field1String;
            updatedState.primaryGraphic = testArtwork;
            updatedState.secondaryGraphic = testArtwork2;

            testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
            [testOp start];
        });

        it(@"should reset to current screen data for equivalent properties in updated state and error state", ^{
            // Create an error state that matches the updated state, which should reset the updated state
            SDLTextAndGraphicState *errorState = [[SDLTextAndGraphicState alloc] init];
            errorState.textField1 = updatedState.textField1;
            errorState.primaryGraphic = updatedState.primaryGraphic;
            errorState.secondaryGraphic = updatedState.secondaryGraphic;

            [testOp updateTargetStateWithErrorState:errorState];

            expect(updatedState.textField1).to(beNil());
            expect(updatedState.primaryGraphic).to(beNil());
            expect(updatedState.secondaryGraphic).to(beNil());
        });

        it(@"should not reset to current screen data for non equivalent properties in updated state and error state", ^{
            // Create an error state that does not match the updated state, which should not reset the updated state
            SDLTextAndGraphicState *errorState = [[SDLTextAndGraphicState alloc] init];
            errorState.textField1 = nil;
            errorState.primaryGraphic = nil;
            errorState.secondaryGraphic = nil;

            [testOp updateTargetStateWithErrorState:errorState];

            expect(updatedState.textField1).toNot(beNil());
            expect(updatedState.primaryGraphic).toNot(beNil());
            expect(updatedState.secondaryGraphic).toNot(beNil());
        });
    });

    // updating image fields
    describe(@"updating image fields", ^{
        beforeEach(^{
            windowCapability = [[SDLWindowCapability alloc] init];
            windowCapability.textFields = @[fieldLine1, fieldLine2, fieldLine3, fieldLine4];
            windowCapability.imageFields = @[fieldGraphic, fieldSecondaryGraphic];
        });

        // when the images are already available on the head unit
        context(@"when the images are already available on the head unit", ^{
            beforeEach(^{
                OCMStub([mockFileManager hasUploadedFile:[OCMArg isNotNil]]).andReturn(YES);
            });

            // when only the primary graphic is supported
            context(@"when only the primary graphic is supported", ^{
                beforeEach(^{
                    windowCapability.imageFields = @[fieldGraphic];

                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.primaryGraphic = testArtwork;
                    updatedState.secondaryGraphic = testArtwork2;
                });

                it(@"should send a show and not upload any artworks", ^{
                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    expect(testConnectionManager.receivedRequests).to(haveCount(1));
                    SDLShow *firstSentRequest = testConnectionManager.receivedRequests[0];
                    expect(firstSentRequest.mainField1).to(equal(field1String));
                    expect(firstSentRequest.mainField2).to(beEmpty());
                    expect(firstSentRequest.graphic).toNot(beNil());
                    expect(firstSentRequest.secondaryGraphic).to(beNil());
                    OCMReject([mockFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]);
                });

                it(@"should properly overwrite artwork", ^{
                    OCMStub([mockFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
                    SDLArtwork *testArtwork3 = [[SDLArtwork alloc] initWithData:[@"Test data 3" dataUsingEncoding:NSUTF8StringEncoding] name:testArtworkName fileExtension:@"png" persistent:NO];
                    testArtwork3.overwrite = YES;

                    SDLTextAndGraphicState *updatedState2 = [[SDLTextAndGraphicState alloc] init];
                    updatedState2.textField1 = field1String;
                    updatedState2.primaryGraphic = testArtwork3;
                    updatedState2.secondaryGraphic = testArtwork2;

                    SDLTextAndGraphicUpdateOperation *testOp2 = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:updatedState newState:updatedState2 currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp2 start];

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];

                    OCMVerify([mockFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]);
                });
            });

            // when both image fields are supported
            context(@"when both image fields are supported", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.primaryGraphic = testArtwork;
                    updatedState.secondaryGraphic = testArtwork2;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];
                });

                it(@"should send a show and not upload any artworks", ^{
                    expect(testConnectionManager.receivedRequests).to(haveCount(1));
                    SDLShow *firstSentRequest = testConnectionManager.receivedRequests[0];
                    expect(firstSentRequest.mainField1).to(equal(field1String));
                    expect(firstSentRequest.mainField2).to(beEmpty());
                    expect(firstSentRequest.graphic).toNot(beNil());
                    expect(firstSentRequest.secondaryGraphic).toNot(beNil());
                });
            });
        });

        // when images are not on the head unit
        context(@"when images are not on the head unit", ^{
            beforeEach(^{
                OCMStub([mockFileManager hasUploadedFile:[OCMArg isNotNil]]).andReturn(NO);
                OCMStub([mockFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:([OCMArg invokeBlockWithArgs:[NSNull null], [NSNull null], nil])]);
            });

            // when there is text to update as well
            context(@"when there is text to update as well", ^{
                beforeEach(^{
                    OCMStub([mockFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.primaryGraphic = testArtwork;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {
                        receivedState = newScreenData;
                        receivedError = error;
                    } updateCompletionHandler:^(NSError * _Nullable error) {
                        completionError = error;
                    }];
                    [testOp start];
                });

                context(@"when the text show succeeds", ^{
                    it(@"should then upload the images, then send the full show", ^{
                        // First the text only show should be sent
                        expect(testConnectionManager.receivedRequests).to(haveCount(1));
                        SDLShow *firstSentRequest = testConnectionManager.receivedRequests[0];
                        expect(firstSentRequest.mainField1).to(equal(field1String));
                        expect(firstSentRequest.graphic).to(beNil());
                        [testConnectionManager respondToLastRequestWithResponse:successShowResponse];

                        // Then the images should be uploaded
                        OCMExpect([mockFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]);

                        // Then the full show should be sent, this is currently not testable because the `mockFileManager hasUploadedFile` should change mid-call of `uploadArtworks` after the artwork is uploaded but before the final Show is sent in sdl_createImageOnlyShowWithPrimaryArtwork.
    //                    expect(testConnectionManager.receivedRequests).to(haveCount(2));
    //                    SDLShow *secondSentRequest = testConnectionManager.receivedRequests[1];
    //                    expect(secondSentRequest.mainField1).to(beNil());
    //                    expect(secondSentRequest.graphic).toNot(beNil());
                    });
                });

                context(@"when the text show fails", ^{
                    it(@"should return an error and finish the operation", ^{
                        // First the text only show should be sent
                        expect(testConnectionManager.receivedRequests).to(haveCount(1));
                        SDLShow *firstSentRequest = testConnectionManager.receivedRequests[0];
                        expect(firstSentRequest.mainField1).to(equal(field1String));
                        expect(firstSentRequest.graphic).to(beNil());
                        [testConnectionManager respondToLastRequestWithResponse:failShowResponse];

                        // Then it should return a failure and finish
                        expect(receivedState).to(beNil());
                        expect(receivedError).toNot(beNil());
                        expect(receivedError.userInfo[NSUnderlyingErrorKey]).toNot(beNil());
                        expect(receivedError.userInfo[SDLTextAndGraphicFailedScreenStateErrorKey]).to(equal(updatedState));
                        expect(completionError).toNot(beNil());

                        expect(testOp.isFinished).to(beTrue());
                    });
                });

                context(@"when cancelled before the text show returns", ^{
                    it(@"should return an error and finish the operation", ^{
                        // First the text only show should be sent
                        expect(testConnectionManager.receivedRequests).to(haveCount(1));
                        SDLShow *firstSentRequest = testConnectionManager.receivedRequests[0];
                        expect(firstSentRequest.mainField1).to(equal(field1String));
                        expect(firstSentRequest.graphic).to(beNil());

                        [testOp cancel];
                        [testConnectionManager respondToLastRequestWithResponse:successShowResponse];

                        // Then it should return a failure and finish
                        expect(receivedState).toNot(beNil());
                        expect(receivedError).to(beNil());
                        expect(completionError).toNot(beNil());

                        expect(testOp.isFinished).to(beTrue());
                    });
                });
            });

            // when there is no text to update
            context(@"when there is no text to update", ^{
                beforeEach(^{
                    OCMStub([mockFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.primaryGraphic = testArtwork;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];
                });

                it(@"should just upload the images, then send the full show", ^{
                    // First the text only show should be sent
                    expect(testConnectionManager.receivedRequests).to(haveCount(1));
                    SDLShow *firstSentRequest = testConnectionManager.receivedRequests[0];
                    expect(firstSentRequest.mainField1).to(beEmpty());
                    expect(firstSentRequest.graphic).to(beNil());
                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];

                    // Then the images should be uploaded
                    OCMExpect([mockFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]);

                    // Then the full show should be sent, this is currently not testable because the `mockFileManager hasUploadedFile` should change mid-call of `uploadArtworks` after the artwork is uploaded but before the final Show is sent in sdl_createImageOnlyShowWithPrimaryArtwork.
//                    expect(testConnectionManager.receivedRequests).to(haveCount(2));
//                    SDLShow *secondSentRequest = testConnectionManager.receivedRequests[1];
//                    expect(secondSentRequest.mainField1).to(beEmpty());
//                    expect(secondSentRequest.graphic).toNot(beNil());
                });
            });

            // when the image is a static icon
            context(@"when the image is a static icon", ^{
                beforeEach(^{
                    OCMStub([mockFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(NO);
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.primaryGraphic = testStaticIcon;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];
                });

                it(@"should not upload the artwork", ^{
                    // The full show should be sent immediately
                    expect(testConnectionManager.receivedRequests).to(haveCount(1));
                    SDLShow *firstSentRequest = testConnectionManager.receivedRequests[0];
                    expect(firstSentRequest.mainField1).to(beEmpty());
                    expect(firstSentRequest.graphic).toNot(beNil());
                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];

                    // Then the images should be uploaded
                    OCMReject([mockFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]);
                });
            });
        });

        // when an image fails to upload to the remote
        describe(@"when an image fails to upload to the remote", ^{
            context(@"if the images for the primary and secondary graphics fail the upload process", ^{
                beforeEach(^{
                    OCMStub([mockFileManager hasUploadedFile:[OCMArg isNotNil]]).andReturn(NO);
                    OCMStub([mockFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
                    NSArray<NSString *> *testSuccessfulArtworks = @[];
                    NSError *testError = [NSError errorWithDomain:@"errorDomain"
                                                             code:9
                                                         userInfo:@{testArtwork.name:@"error 1", testArtwork2.name:@"error 2"}
                                          ];
                    OCMStub([mockFileManager uploadArtworks:[OCMArg isNotNil] completionHandler:([OCMArg invokeBlockWithArgs:testSuccessfulArtworks, testError, nil])]);

                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.primaryGraphic = testArtwork;
                    updatedState.secondaryGraphic = testArtwork2;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];
                });

                it(@"should skip sending an update", ^{
                    // Just the empty text show
                    expect(testConnectionManager.receivedRequests).to(haveCount(1));

                    SDLShow *sentShow = testConnectionManager.receivedRequests[0];
                    expect(sentShow.graphic).to(beNil());
                    expect(sentShow.secondaryGraphic).to(beNil());
                });
            });

            context(@"if only one of images for the primary and secondary graphics fails to upload", ^{
                it(@"should show the primary graphic even if the secondary graphic upload fails", ^{
                    OCMStub([mockFileManager hasUploadedFile:testArtwork]).andReturn(YES);
                    OCMStub([mockFileManager hasUploadedFile:testArtwork2]).andReturn(NO);
                    NSArray<NSString *> *testSuccessfulArtworks = @[testArtwork.name];
                    NSError *testError = [NSError errorWithDomain:@"errorDomain" code:9 userInfo:@{testArtwork2.name:@"error 2"}];
                    OCMStub([mockFileManager uploadArtworks:[OCMArg isNotNil] progressHandler:[OCMArg isNotNil] completionHandler:([OCMArg invokeBlockWithArgs:testSuccessfulArtworks, testError, nil])]);
                    OCMStub([mockFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.primaryGraphic = testArtwork;
                    updatedState.secondaryGraphic = testArtwork2;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    expect(testConnectionManager.receivedRequests).to(haveCount(1));
                    SDLShow *receivedShow = testConnectionManager.receivedRequests[0];
                    expect(receivedShow.mainField1).to(equal(field1String));
                    expect(receivedShow.graphic.value).to(beNil());
                    expect(receivedShow.secondaryGraphic).to(beNil());

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                    expect(testConnectionManager.receivedRequests).to(haveCount(2));
                    SDLShow *secondReceivedShow = testConnectionManager.receivedRequests[1];
                    expect(secondReceivedShow.mainField1).to(beNil());
                    expect(secondReceivedShow.graphic.value).to(equal(testArtwork.name));
                    expect(secondReceivedShow.secondaryGraphic).to(beNil());
                });

                it(@"Should show the secondary graphic even if the primary graphic upload fails", ^{
                    OCMStub([mockFileManager hasUploadedFile:testArtwork]).andReturn(NO);
                    OCMStub([mockFileManager hasUploadedFile:testArtwork2]).andReturn(YES);
                    NSArray<NSString *> *testSuccessfulArtworks = @[testArtwork2.name];
                    NSError *testError = [NSError errorWithDomain:@"errorDomain" code:9 userInfo:@{testArtwork.name:@"error 2"}];
                    OCMStub([mockFileManager uploadArtworks:[OCMArg isNotNil] progressHandler:[OCMArg isNotNil] completionHandler:([OCMArg invokeBlockWithArgs:testSuccessfulArtworks, testError, nil])]);
                    OCMStub([mockFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.textField1 = field1String;
                    updatedState.primaryGraphic = testArtwork;
                    updatedState.secondaryGraphic = testArtwork2;

                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:windowCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {} updateCompletionHandler:nil];
                    [testOp start];

                    expect(testConnectionManager.receivedRequests).to(haveCount(1));
                    SDLShow *receivedShow = testConnectionManager.receivedRequests[0];
                    expect(receivedShow.mainField1).to(equal(field1String));
                    expect(receivedShow.graphic).to(beNil());
                    expect(receivedShow.secondaryGraphic).to(beNil());

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                    expect(testConnectionManager.receivedRequests).to(haveCount(2));
                    SDLShow *secondReceivedShow = testConnectionManager.receivedRequests[1];
                    expect(secondReceivedShow.mainField1).to(beNil());
                    expect(secondReceivedShow.graphic).to(beNil());
                    expect(secondReceivedShow.secondaryGraphic.value).to(equal(testArtwork2.name));
                });
            });
        });
    });

    // changing a layout
    describe(@"changing a layout", ^{
        // on less than RPC 6.0
        context(@"on less than RPC 6.0", ^{
            beforeEach(^{
                [SDLGlobals sharedGlobals].rpcVersion = [SDLVersion versionWithString:@"5.0.0"];
            });

            // by itself
            context(@"by itself", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.templateConfig = newConfiguration;
                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:allEnabledCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {
                        receivedState = newScreenData;
                        receivedError = error;
                    } updateCompletionHandler:nil];
                    [testOp start];
                });

                it(@"should send a set display layout, then update the screen data, then send a Show with no data", ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
                    SDLSetDisplayLayout *sentRPC = testConnectionManager.receivedRequests.firstObject;
                    expect(sentRPC).to(beAnInstanceOf([SDLSetDisplayLayout class]));
#pragma clang diagnostic pop
                    expect(sentRPC.displayLayout).to(equal(newConfiguration.template));

                    [testConnectionManager respondToLastRequestWithResponse:successSetDisplayLayoutResponse];
                    expect(receivedState.templateConfig).toNot(beNil());
                    expect(receivedError).to(beNil());

                    SDLShow *sentRPC2 = testConnectionManager.receivedRequests[1];
                    expect(sentRPC2).to(beAnInstanceOf([SDLShow class]));
                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                    expect(testOp.isFinished).to(beTrue());
                });
            });

            // with other text
            context(@"with other text", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.templateConfig = newConfiguration;
                    updatedState.textField1 = field1String;
                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:allEnabledCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {
                        receivedState = newScreenData;
                        receivedError = error;
                    } updateCompletionHandler:^(NSError * _Nullable error) {
                        completionError = error;
                    }];
                    [testOp start];
                });

                // should send a set display layout, then update the screen data, then send a Show with data and then update the screen data again
                it(@"should send a set display layout, then update the screen data, then send a Show with data and then update the screen data again", ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
                    SDLSetDisplayLayout *sentRPC = testConnectionManager.receivedRequests.firstObject;
                    expect(sentRPC).to(beAnInstanceOf([SDLSetDisplayLayout class]));
#pragma clang diagnostic pop
                    expect(sentRPC.displayLayout).to(equal(newConfiguration.template));

                    [testConnectionManager respondToLastRequestWithResponse:successSetDisplayLayoutResponse];
                    expect(receivedState.templateConfig).toNot(beNil());
                    expect(receivedState.textField1).to(beNil());
                    expect(receivedError).to(beNil());

                    SDLShow *sentRPC2 = testConnectionManager.receivedRequests[1];
                    expect(sentRPC2).to(beAnInstanceOf([SDLShow class]));
                    expect(sentRPC2.mainField1).to(equal(field1String));
                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                    expect(receivedState.templateConfig).toNot(beNil());
                    expect(receivedState.textField1).toNot(beNil());
                    expect(receivedError).to(beNil());
                    expect(completionError).to(beNil());
                    expect(testOp.isFinished).to(beTrue());
                });

                // when cancelled before finishing
                describe(@"when cancelled before finishing", ^{
                    it(@"should finish the operation with the set display layout data in the current data handler and set an update superseded error in the update completion handler", ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
                        SDLSetDisplayLayout *sentRPC = testConnectionManager.receivedRequests.firstObject;
                        expect(sentRPC).to(beAnInstanceOf([SDLSetDisplayLayout class]));
#pragma clang diagnostic pop
                        expect(sentRPC.displayLayout).to(equal(newConfiguration.template));

                        [testOp cancel];
                        [testConnectionManager respondToLastRequestWithResponse:successSetDisplayLayoutResponse];
                        expect(receivedState).toNot(beNil());
                        expect(receivedError).to(beNil());
                        expect(completionError).toNot(beNil());

                        expect(testOp.isFinished).to(beTrue());

                    });
                });

                // when it receives a set display layout failure
                describe(@"when it receives a set display layout failure", ^{
                    it(@"should send a set display layout, then reset the screen data, then finish the operation", ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
                        SDLSetDisplayLayout *sentRPC = testConnectionManager.receivedRequests.firstObject;
                        expect(sentRPC).to(beAnInstanceOf([SDLSetDisplayLayout class]));
#pragma clang diagnostic pop
                        expect(sentRPC.displayLayout).to(equal(newConfiguration.template));

                        [testConnectionManager respondToLastRequestWithResponse:failSetDisplayLayoutResponse];
                        expect(receivedState).to(beNil());
                        expect(receivedError).toNot(beNil());
                        expect(completionError).toNot(beNil());

                        expect(testOp.isFinished).to(beTrue());
                    });
                });
            });
        });

        // on greater or equal than RPC 6.0
        context(@"on greater or equal than RPC 6.0", ^{
            beforeEach(^{
                [SDLGlobals sharedGlobals].rpcVersion = [SDLVersion versionWithString:@"6.0.0"];
            });

            // by itself
            context(@"by itself", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.templateConfig = newConfiguration;
                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:allEnabledCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {
                        receivedState = newScreenData;
                        receivedError = error;
                    } updateCompletionHandler:nil];
                    [testOp start];
                });

                it(@"should send a show, then update the screen data", ^{
                    SDLShow *sentRPC = testConnectionManager.receivedRequests.firstObject;
                    expect(sentRPC).to(beAnInstanceOf([SDLShow class]));
                    expect(sentRPC.templateConfiguration).to(equal(newConfiguration));

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                    expect(receivedState.templateConfig).toNot(beNil());
                    expect(receivedState.textField1).to(beNil());
                    expect(receivedError).to(beNil());
                    expect(testOp.isFinished).to(beTrue());
                });
            });

            // with other text
            context(@"with other text that isn't supported", ^{
                beforeEach(^{
                    updatedState = [[SDLTextAndGraphicState alloc] init];
                    updatedState.templateConfig = newConfiguration;
                    updatedState.textField1 = field1String;
                    testOp = [[SDLTextAndGraphicUpdateOperation alloc] initWithConnectionManager:testConnectionManager fileManager:mockFileManager currentCapabilities:allEnabledCapability currentScreenData:emptyCurrentData newState:updatedState currentScreenDataUpdatedHandler:^(SDLTextAndGraphicState * _Nullable newScreenData, NSError * _Nullable error) {
                        receivedState = newScreenData;
                        receivedError = error;
                    } updateCompletionHandler:nil];
                    [testOp start];
                });

                it(@"should send a show, then update all screen data", ^{
                    SDLShow *sentRPC = testConnectionManager.receivedRequests.firstObject;
                    expect(sentRPC).to(beAnInstanceOf([SDLShow class]));
                    expect(sentRPC.templateConfiguration).to(equal(newConfiguration));

                    [testConnectionManager respondToLastRequestWithResponse:successShowResponse];
                    expect(receivedState.templateConfig).toNot(beNil());
                    expect(receivedState.textField1).to(equal(field1String));
                    expect(receivedError).to(beNil());
                    expect(testOp.isFinished).to(beTrue());
                });

                // when it receives a show failure
                describe(@"when it receives a show failure", ^{
                    it(@"it should send a set display layout, then reset the screen data, then do nothing else", ^{
                        SDLShow *sentRPC = testConnectionManager.receivedRequests.firstObject;
                        expect(sentRPC).to(beAnInstanceOf([SDLShow class]));
                        expect(sentRPC.templateConfiguration).to(equal(newConfiguration));

                        [testConnectionManager respondToLastRequestWithResponse:failShowResponse];
                        expect(receivedState).to(beNil());
                        expect(receivedError).toNot(beNil());
                        expect(receivedError.userInfo[NSUnderlyingErrorKey]).toNot(beNil());
                        expect(receivedError.userInfo[SDLTextAndGraphicFailedScreenStateErrorKey]).to(equal(updatedState));

                        expect(testOp.isFinished).to(beTrue());
                    });
                });
            });
        });
    });
});

QuickSpecEnd