summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-09-16 13:24:08 -0400
committerJoel Fischer <joeljfischer@gmail.com>2020-09-16 13:24:08 -0400
commit5a48765845f6b3801443dcf2124e07a1d2bbd850 (patch)
tree2db3b60b6d39ac6c63b5b87fa0534d734d268f5a
parentf96aa06986631601e22f65662264e45232677fd5 (diff)
downloadsdl_ios-5a48765845f6b3801443dcf2124e07a1d2bbd850.tar.gz
Add tests for SetDisplayLayout cancel
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m29
1 files changed, 26 insertions, 3 deletions
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m
index f609d3486..64168926e 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m
@@ -72,6 +72,7 @@ describe(@"the text and graphic operation", ^{
__block SDLTextAndGraphicState *receivedState = nil;
__block NSError *receivedError = nil;
+ __block NSError *completionError = nil;
beforeEach(^{
testConnectionManager = [[TestConnectionManager alloc] init];
@@ -1034,10 +1035,13 @@ describe(@"the text and graphic operation", ^{
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];
+ } 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", ^{
SDLSetDisplayLayout *sentRPC = testConnectionManager.receivedRequests.firstObject;
expect(sentRPC).to(beAnInstanceOf([SDLSetDisplayLayout class]));
@@ -1055,20 +1059,39 @@ describe(@"the text and graphic operation", ^{
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", ^{
+ fit(@"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", ^{
+ SDLSetDisplayLayout *sentRPC = testConnectionManager.receivedRequests.firstObject;
+ expect(sentRPC).to(beAnInstanceOf([SDLSetDisplayLayout class]));
+ 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(@"it should send a set display layout, then reset the screen data, then do nothing else", ^{
+ it(@"should send a set display layout, then reset the screen data, then finish the operation", ^{
SDLSetDisplayLayout *sentRPC = testConnectionManager.receivedRequests.firstObject;
expect(sentRPC).to(beAnInstanceOf([SDLSetDisplayLayout class]));
expect(sentRPC.displayLayout).to(equal(newConfiguration.template));
[testConnectionManager respondToLastRequestWithResponse:failSetDisplayLayoutResponse];
expect(receivedState).to(beNil());
- expect(receivedState).to(beNil());
expect(receivedError).toNot(beNil());
+ expect(completionError).toNot(beNil());
expect(testOp.isFinished).to(beTrue());
});