diff options
author | NicoleYarroch <nicole@livio.io> | 2019-12-03 11:06:06 -0500 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2019-12-03 11:06:06 -0500 |
commit | 0b8374facf2c010dc45bdef5f4813fe2f3ae4cf5 (patch) | |
tree | 6d45c545945774ca305853371ea9670d5311ca4e /SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m | |
parent | b5f4f611d3979d3112639a208fef67c3b85a08d8 (diff) | |
download | sdl_ios-0b8374facf2c010dc45bdef5f4813fe2f3ae4cf5.tar.gz |
Added test cases to make sure operation finishes
Diffstat (limited to 'SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m')
-rw-r--r-- | SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m index 6a68c25be..8c8714aea 100644 --- a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m +++ b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m @@ -123,7 +123,7 @@ describe(@"a soft button replace operation", ^{ testSoftButtonObjects = @[button1, button2]; }); - context(@"but we don't support artworks", ^{ + fcontext(@"but the HMI does not support artworks", ^{ beforeEach(^{ SDLSoftButtonCapabilities *capabilities = [[SDLSoftButtonCapabilities alloc] init]; capabilities.imageSupported = @NO; @@ -132,9 +132,11 @@ describe(@"a soft button replace operation", ^{ [testOp start]; }); - it(@"should not send artworks", ^{ + it(@"should not upload any artworks", ^{ OCMReject([testFileManager uploadArtworks:[OCMArg any] completionHandler:[OCMArg any]]); + }); + it(@"should send the button text", ^{ NSArray<SDLShow *> *sentRequests = testConnectionManager.receivedRequests; expect(sentRequests).to(haveCount(1)); expect(sentRequests.firstObject.mainField1).to(equal(testMainField1)); @@ -147,9 +149,31 @@ describe(@"a soft button replace operation", ^{ expect(sentRequests.firstObject.softButtons.lastObject.image).to(beNil()); expect(sentRequests.firstObject.softButtons.lastObject.type).to(equal(SDLSoftButtonTypeText)); }); + + context(@"When a response is received to the text upload", ^{ + it(@"should finish the operation on a successful response", ^{ + SDLRPCResponse *successResponse = [[SDLRPCResponse alloc] init]; + successResponse.success = @YES; + successResponse.resultCode = SDLResultSuccess; + [testConnectionManager respondToLastRequestWithResponse:successResponse]; + + expect(testOp.isFinished).to(beTrue()); + expect(testOp.isExecuting).to(beFalse()); + }); + + it(@"should finish the operation on a failed response", ^{ + SDLRPCResponse *failedResponse = [[SDLRPCResponse alloc] init]; + failedResponse.success = @NO; + failedResponse.resultCode = SDLResultRejected; + [testConnectionManager respondToLastRequestWithResponse:failedResponse]; + + expect(testOp.isFinished).to(beTrue()); + expect(testOp.isExecuting).to(beFalse()); + }); + }); }); - context(@"but we don't support artworks and some buttons are image-only", ^{ + context(@"but the HMI does not support artworks and some buttons are image-only", ^{ __block NSArray<SDLSoftButtonObject *> *testImageOnlySoftButtonObjects = nil; beforeEach(^{ @@ -178,7 +202,7 @@ describe(@"a soft button replace operation", ^{ }); }); - context(@"and we support artworks", ^{ + context(@"and the HMI supports artworks", ^{ __block SDLSoftButtonCapabilities *buttonCapabilities = nil; beforeEach(^{ |