summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2019-12-03 11:17:11 -0500
committerNicoleYarroch <nicole@livio.io>2019-12-03 11:17:11 -0500
commitd9b26b37e3cf1ead9b18bd5ea8f9ceaf058bebba (patch)
tree0bd57cefd7f1c7ed241753acf7823fdd92c5ffad
parent0b8374facf2c010dc45bdef5f4813fe2f3ae4cf5 (diff)
downloadsdl_ios-bugfix/issue_1474_soft_buttons_switching_templates_bug.tar.gz
-rw-r--r--SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m83
1 files changed, 76 insertions, 7 deletions
diff --git a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m
index 8c8714aea..f2b09c66e 100644
--- a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m
+++ b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m
@@ -60,6 +60,9 @@ describe(@"a soft button replace operation", ^{
__block NSString *testMainField1 = @"Test main field 1";
+ __block SDLRPCResponse *successResponse = nil;
+ __block SDLRPCResponse *failedResponse = nil;
+
beforeEach(^{
resultError = nil;
hasCalledOperationCompletionHandler = NO;
@@ -84,6 +87,14 @@ describe(@"a soft button replace operation", ^{
button4 = [[SDLSoftButtonObject alloc] initWithName:object4Name state:object4State1 handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {}];;
OCMStub([testFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg invokeBlock] completionHandler:[OCMArg invokeBlock]]);
+
+ successResponse = [[SDLRPCResponse alloc] init];
+ successResponse.success = @YES;
+ successResponse.resultCode = SDLResultSuccess;
+
+ failedResponse = [[SDLRPCResponse alloc] init];
+ failedResponse.success = @NO;
+ failedResponse.resultCode = SDLResultRejected;
});
it(@"should have a priority of 'normal'", ^{
@@ -114,6 +125,22 @@ describe(@"a soft button replace operation", ^{
expect(sentRequests.firstObject.softButtons.firstObject.image).to(beNil());
expect(sentRequests.firstObject.softButtons.firstObject.type).to(equal(SDLSoftButtonTypeText));
});
+
+ context(@"When a response is received to the text upload", ^{
+ it(@"should finish the operation on a successful response", ^{
+ [testConnectionManager respondToLastRequestWithResponse:successResponse];
+
+ expect(testOp.isFinished).to(beTrue());
+ expect(testOp.isExecuting).to(beFalse());
+ });
+
+ it(@"should finish the operation on a failed response", ^{
+ [testConnectionManager respondToLastRequestWithResponse:failedResponse];
+
+ expect(testOp.isFinished).to(beTrue());
+ expect(testOp.isExecuting).to(beFalse());
+ });
+ });
});
context(@"with artworks", ^{
@@ -123,7 +150,7 @@ describe(@"a soft button replace operation", ^{
testSoftButtonObjects = @[button1, button2];
});
- fcontext(@"but the HMI does not support artworks", ^{
+ context(@"but the HMI does not support artworks", ^{
beforeEach(^{
SDLSoftButtonCapabilities *capabilities = [[SDLSoftButtonCapabilities alloc] init];
capabilities.imageSupported = @NO;
@@ -152,9 +179,6 @@ describe(@"a soft button replace operation", ^{
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());
@@ -162,9 +186,6 @@ describe(@"a soft button replace operation", ^{
});
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());
@@ -233,6 +254,22 @@ describe(@"a soft button replace operation", ^{
expect(sentRequests.firstObject.softButtons.lastObject.image).toNot(beNil());
expect(sentRequests.firstObject.softButtons.lastObject.type).to(equal(SDLSoftButtonTypeBoth));
});
+
+ context(@"When a response is received to the text upload", ^{
+ it(@"should finish the operation on a successful response", ^{
+ [testConnectionManager respondToLastRequestWithResponse:successResponse];
+
+ expect(testOp.isFinished).to(beTrue());
+ expect(testOp.isExecuting).to(beFalse());
+ });
+
+ it(@"should finish the operation on a failed response", ^{
+ [testConnectionManager respondToLastRequestWithResponse:failedResponse];
+
+ expect(testOp.isFinished).to(beTrue());
+ expect(testOp.isExecuting).to(beFalse());
+ });
+ });
});
context(@"when the artworks need uploading", ^{
@@ -263,6 +300,22 @@ describe(@"a soft button replace operation", ^{
expect(sentRequests.firstObject.softButtons.firstObject.image).toNot(beNil());
expect(sentRequests.firstObject.softButtons.firstObject.type).to(equal(SDLSoftButtonTypeBoth));
});
+
+ context(@"When a response is received to the text upload", ^{
+ it(@"should finish the operation on a successful response", ^{
+ [testConnectionManager respondToLastRequestWithResponse:successResponse];
+
+ expect(testOp.isFinished).to(beTrue());
+ expect(testOp.isExecuting).to(beFalse());
+ });
+
+ it(@"should finish the operation on a failed response", ^{
+ [testConnectionManager respondToLastRequestWithResponse:failedResponse];
+
+ expect(testOp.isFinished).to(beTrue());
+ expect(testOp.isExecuting).to(beFalse());
+ });
+ });
});
context(@"when artwork are not already on the system", ^{
@@ -302,6 +355,22 @@ describe(@"a soft button replace operation", ^{
expect(sentRequests.lastObject.softButtons.lastObject.image).toNot(beNil());
expect(sentRequests.lastObject.softButtons.lastObject.type).to(equal(SDLSoftButtonTypeBoth));
});
+
+ context(@"When a response is received to the text upload", ^{
+ it(@"should finish the operation on a successful response", ^{
+ [testConnectionManager respondToLastRequestWithResponse:successResponse];
+
+ expect(testOp.isFinished).to(beTrue());
+ expect(testOp.isExecuting).to(beFalse());
+ });
+
+ it(@"should finish the operation on a failed response", ^{
+ [testConnectionManager respondToLastRequestWithResponse:failedResponse];
+
+ expect(testOp.isFinished).to(beTrue());
+ expect(testOp.isExecuting).to(beFalse());
+ });
+ });
});
});
});