diff options
author | Frank Elias <francois.elias@livio.io> | 2020-11-19 09:15:38 -0500 |
---|---|---|
committer | Frank Elias <francois.elias@livio.io> | 2020-11-19 09:15:38 -0500 |
commit | e1f50989e80f09708ce833068e44333d696d3cc1 (patch) | |
tree | 905d201708ca95bc4268bd7d1db91a25d3d2a3d1 | |
parent | d6e31a52201a5de26310404d62f8a7756b9313eb (diff) | |
download | sdl_ios-e1f50989e80f09708ce833068e44333d696d3cc1.tar.gz |
Added unit tests
3 files changed, 51 insertions, 0 deletions
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m index c36e574fe..c6b8fa9bc 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m @@ -25,6 +25,7 @@ describe(@"a preload choices operation", ^{ __block NSString *testDisplayName = @"SDL_GENERIC"; __block NSData *cellArtData = [@"testart" dataUsingEncoding:NSUTF8StringEncoding]; + __block NSData *cellArtData2 = [@"testart2" dataUsingEncoding:NSUTF8StringEncoding]; __block BOOL hasCalledOperationCompletionHandler = NO; __block NSError *resultError = nil; @@ -60,6 +61,7 @@ describe(@"a preload choices operation", ^{ __block NSSet<SDLChoiceCell *> *cellsWithStaticIcon = nil; __block NSString *art1Name = @"Art1Name"; __block NSString *art2Name = @"Art2Name"; + __block SDLArtwork *cell1Art2 = [[SDLArtwork alloc] initWithData:cellArtData2 name:art1Name fileExtension:@"png" persistent:NO]; beforeEach(^{ SDLArtwork *cell1Art = [[SDLArtwork alloc] initWithData:cellArtData name:art1Name fileExtension:@"png" persistent:NO]; @@ -145,6 +147,25 @@ describe(@"a preload choices operation", ^{ }] completionHandler:[OCMArg any]]); expect(@(testOp.currentState)).to(equal(SDLPreloadChoicesOperationStatePreloadingChoices)); }); + + it(@"should properly override artwork", ^{ + cell1Art2.overwrite = YES; + SDLChoiceCell *cell1WithArt = [[SDLChoiceCell alloc] initWithText:@"Cell1" artwork:cell1Art2 voiceCommands:nil]; + + SDLArtwork *cell2Art = [[SDLArtwork alloc] initWithData:cellArtData name:art2Name fileExtension:@"png" persistent:NO]; + SDLChoiceCell *cell2WithArtAndSecondary = [[SDLChoiceCell alloc] initWithText:@"Cell2" secondaryText:nil tertiaryText:nil voiceCommands:nil artwork:cell2Art secondaryArtwork:cell2Art]; + + SDLArtwork *staticIconArt = [SDLArtwork artworkWithStaticIcon:SDLStaticIconNameDate]; + SDLChoiceCell *cellWithStaticIcon = [[SDLChoiceCell alloc] initWithText:@"Static Icon" secondaryText:nil tertiaryText:nil voiceCommands:nil artwork:staticIconArt secondaryArtwork:nil]; + + cellsWithArtwork = [NSSet setWithArray:@[cell1WithArt, cell2WithArtAndSecondary]]; + cellsWithStaticIcon = [NSSet setWithArray:@[cellWithStaticIcon]]; + testOp = [[SDLPreloadChoicesOperation alloc] initWithConnectionManager:testConnectionManager fileManager:testFileManager displayName:testDisplayName windowCapability:windowCapability isVROptional:NO cellsToPreload:cellsWithArtwork]; + [testOp start]; + + OCMExpect([testFileManager uploadArtworks:[OCMArg any] completionHandler:[OCMArg any]]); + OCMVerify([testFileManager uploadArtworks:[OCMArg any] completionHandler:[OCMArg any]]); + }); }); context(@"when artworks are static icons", ^{ diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m index 77760bb07..09480a2b5 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m @@ -53,6 +53,7 @@ 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 *testArtwork3 = [[SDLArtwork alloc] initWithData:[@"Test data 3" dataUsingEncoding:NSUTF8StringEncoding] name:testArtworkName fileExtension:@"png" persistent:NO]; SDLArtwork *testStaticIcon = [SDLArtwork artworkWithStaticIcon:SDLStaticIconNameDate]; SDLTemplateConfiguration *newConfiguration = [[SDLTemplateConfiguration alloc] initWithPredefinedLayout:SDLPredefinedLayoutTilesOnly]; @@ -99,6 +100,7 @@ describe(@"the text and graphic operation", ^{ emptyCurrentData = [[SDLTextAndGraphicState alloc] init]; receivedState = nil; receivedError = nil; + testArtwork3.overwrite = YES; // Default to the max version [SDLGlobals sharedGlobals].rpcVersion = [SDLVersion versionWithString:SDLMaxProxyRPCVersion]; @@ -833,6 +835,18 @@ describe(@"the text and graphic operation", ^{ expect(firstSentRequest.graphic).toNot(beNil()); expect(firstSentRequest.secondaryGraphic).to(beNil()); }); + + it(@"should properly override artwork", ^{ + 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]; + + OCMVerify([mockFileManager uploadArtworks:[OCMArg any] completionHandler:[OCMArg any]]); + }); }); // when both image fields are supported diff --git a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m index 623ec427c..28911ad57 100644 --- a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m +++ b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m @@ -44,6 +44,7 @@ describe(@"a soft button replace operation", ^{ __block NSString *object2State2ArtworkName = @"O2S2 Artwork"; __block SDLArtwork *object2State1Art = nil; __block SDLArtwork *object2State2Art = nil; + __block SDLArtwork *object2State11Art = nil; __block SDLSoftButtonState *object2State1 = nil; __block SDLSoftButtonState *object2State2 = nil; __block SDLSoftButtonObject *buttonWithTextAndImage = nil; @@ -97,6 +98,8 @@ describe(@"a soft button replace operation", ^{ object2State1Art = [[SDLArtwork alloc] initWithData:[@"TestData" dataUsingEncoding:NSUTF8StringEncoding] name:object2State1ArtworkName fileExtension:@"png" persistent:YES]; object2State2Art = [[SDLArtwork alloc] initWithData:[@"TestData2" dataUsingEncoding:NSUTF8StringEncoding] name:object2State2ArtworkName fileExtension:@"png" persistent:YES]; + object2State11Art = [[SDLArtwork alloc] initWithData:[@"TestData11" dataUsingEncoding:NSUTF8StringEncoding] name:object2State1ArtworkName fileExtension:@"png" persistent:YES]; + object2State11Art.overwrite = YES; object2State1 = [[SDLSoftButtonState alloc] initWithStateName:object2State1Name text:object2State1Text artwork:object2State1Art]; object2State2 = [[SDLSoftButtonState alloc] initWithStateName:object2State2Name text:object2State2Text artwork:object2State2Art]; buttonWithTextAndImage = [[SDLSoftButtonObject alloc] initWithName:object2Name states:@[object2State1, object2State2] initialStateName:object2State1.name handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {}]; @@ -296,6 +299,19 @@ describe(@"a soft button replace operation", ^{ expect(sentRequests.firstObject.softButtons.lastObject.type).to(equal(SDLSoftButtonTypeBoth)); }); + it(@"should properly override artwork", ^{ + OCMExpect([testFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]); + + object2State1 = [[SDLSoftButtonState alloc] initWithStateName:object2State1Name text:object2State1Text artwork:object2State11Art]; + buttonWithTextAndImage = [[SDLSoftButtonObject alloc] initWithName:object2Name states:@[object2State1, object2State2] initialStateName:object2State1.name handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {}]; + testSoftButtonObjects = @[buttonWithText, buttonWithTextAndImage]; + testOp = [[SDLSoftButtonReplaceOperation alloc] initWithConnectionManager:testConnectionManager fileManager:testFileManager capabilities:capabilities softButtonObjects:testSoftButtonObjects mainField1:testMainField1]; + + [testOp start]; + + OCMVerify([testFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]); + }); + context(@"When a response is received to the upload", ^{ beforeEach(^{ [testOp start]; |