summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Elias <francois.elias@livio.io>2020-12-02 08:47:41 -0500
committerFrank Elias <francois.elias@livio.io>2020-12-02 08:47:41 -0500
commit503a9c6acf3534c05f34896a5115239944fcd706 (patch)
treed245491822821535bb8377b9259bc729ad5a139e
parent597fd97eb847269d87369b5c106ce9f925ca86ef (diff)
downloadsdl_ios-503a9c6acf3534c05f34896a5115239944fcd706.tar.gz
Unit tests fixes
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m1
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m1
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m7
-rw-r--r--SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m28
4 files changed, 34 insertions, 3 deletions
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m
index c5b633772..66b46072d 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m
@@ -235,6 +235,7 @@ describe(@"menu manager", ^{
});
it(@"should properly overwrite an image cell", ^{
+ OCMStub([mockFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
textAndImageCell = [[SDLMenuCell alloc] initWithTitle:@"Test 2" icon:testArtwork3 voiceCommands:nil handler:^(SDLTriggerSource _Nonnull triggerSource) {}];
testManager.menuCells = @[textAndImageCell, submenuImageCell];
OCMVerify([mockFileManager uploadArtworks:[OCMArg any] completionHandler:[OCMArg any]]);
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m
index a5f161c0c..144f54e3d 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m
@@ -54,6 +54,7 @@ describe(@"a preload choices operation", ^{
windowCapability.textFields = @[primaryTextField];
OCMStub([testFileManager uploadArtworks:[OCMArg any] completionHandler:[OCMArg invokeBlock]]);
+ OCMStub([testFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
});
context(@"with artworks", ^{
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m
index 1afe0a736..b03252c25 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m
@@ -836,6 +836,7 @@ describe(@"the text and graphic operation", ^{
});
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;
@@ -886,6 +887,7 @@ describe(@"the text and graphic operation", ^{
// 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;
@@ -961,6 +963,7 @@ describe(@"the text and graphic operation", ^{
// 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;
@@ -990,6 +993,7 @@ describe(@"the text and graphic operation", ^{
// 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;
@@ -1016,6 +1020,7 @@ describe(@"the text and graphic operation", ^{
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
@@ -1048,6 +1053,7 @@ describe(@"the text and graphic operation", ^{
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;
@@ -1076,6 +1082,7 @@ describe(@"the text and graphic operation", ^{
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;
diff --git a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m
index 54bfc8e52..91751a814 100644
--- a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m
+++ b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m
@@ -165,6 +165,7 @@ describe(@"a soft button replace operation", ^{
context(@"When a response is received to the upload", ^{
beforeEach(^{
+ OCMExpect([testFileManager fileNeedsUpload:[OCMArg any]]);
[testOp start];
});
@@ -269,6 +270,8 @@ describe(@"a soft button replace operation", ^{
beforeEach(^{
capabilities = [[SDLSoftButtonCapabilities alloc] init];
capabilities.imageSupported = @YES;
+// OCMExpect([testFileManager fileNeedsUpload:[OCMArg any]]);
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg isNotNil]]);
});
context(@"when artworks are already on the system", ^{
@@ -277,11 +280,12 @@ describe(@"a soft button replace operation", ^{
testSoftButtonObjects = @[buttonWithText, buttonWithTextAndImage];
testOp = [[SDLSoftButtonReplaceOperation alloc] initWithConnectionManager:testConnectionManager fileManager:testFileManager capabilities:capabilities softButtonObjects:testSoftButtonObjects mainField1:testMainField1];
+// OCMExpect([testFileManager fileNeedsUpload:[OCMArg any]]).andReturn(YES);
});
it(@"should not upload artworks", ^{
OCMReject([testFileManager uploadArtworks:[OCMArg any] progressHandler:nil completionHandler:nil]);
-
+ OCMStub([testFileManager fileNeedsUpload:[OCMArg any]]).andReturn(NO);
[testOp start];
OCMVerifyAllWithDelay(testFileManager, 0.5);
@@ -300,20 +304,24 @@ describe(@"a soft button replace operation", ^{
});
it(@"should properly overwrite artwork", ^{
+// OCMExpect([testFileManager fileNeedsUpload:[OCMArg any]]);
+ OCMStub([testFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
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];
-
+// OCMExpect([testFileManager fileNeedsUpload:[OCMArg isNil]]).andReturn(YES);
[testOp start];
-
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
OCMVerify([testFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]);
});
context(@"When a response is received to the upload", ^{
beforeEach(^{
+// OCMExpect([testFileManager fileNeedsUpload:[OCMArg isNotNil]]);
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
[testOp start];
});
@@ -336,10 +344,12 @@ describe(@"a soft button replace operation", ^{
context(@"when the artworks need uploading", ^{
beforeEach(^{
OCMStub([testFileManager hasUploadedFile:[OCMArg isNotNil]]).andReturn(NO);
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
});
context(@"when artworks are static icons", ^{
beforeEach(^{
+ OCMStub([testFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(NO);
testSoftButtonObjects = @[buttonWithTextAndStaticImage];
testOp = [[SDLSoftButtonReplaceOperation alloc] initWithConnectionManager:testConnectionManager fileManager:testFileManager capabilities:capabilities softButtonObjects:testSoftButtonObjects mainField1:testMainField1];
@@ -384,11 +394,18 @@ describe(@"a soft button replace operation", ^{
});
context(@"when artworks are dynamic icons", ^{
+// beforeEach(^{
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg any]]);
+// });
+
it(@"should upload all artworks", ^{
// Check that the artworks in the initial button states are uploaded
OCMExpect([testFileManager uploadArtworks:@[buttonWithTextAndImage.states[0].artwork] progressHandler:[OCMArg invokeBlock] completionHandler:[OCMArg invokeBlock]]);
+// OCMExpect([testFileManager fileNeedsUpload:[OCMArg any]]);
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
testSoftButtonObjects = @[buttonWithText, buttonWithTextAndImage];
testOp = [[SDLSoftButtonReplaceOperation alloc] initWithConnectionManager:testConnectionManager fileManager:testFileManager capabilities:capabilities softButtonObjects:testSoftButtonObjects mainField1:testMainField1];
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg any]]).andReturn(YES);
[testOp start];
OCMVerifyAllWithDelay(testFileManager, 0.5);
@@ -423,15 +440,19 @@ describe(@"a soft button replace operation", ^{
it(@"should upload all artworks even if the initial state does not have artworks", ^{
OCMReject([testFileManager uploadFiles:[OCMArg any] progressHandler:[OCMArg invokeBlock] completionHandler:[OCMArg invokeBlock]]);
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg any]]).andReturn(NO);
// buttonWithTextAndImage2 has text in the first state and an text and image in the second & third states
testSoftButtonObjects = @[buttonWithTextAndStaticImage, buttonWithTextAndImage2];
testOp = [[SDLSoftButtonReplaceOperation alloc] initWithConnectionManager:testConnectionManager fileManager:testFileManager capabilities:capabilities softButtonObjects:testSoftButtonObjects mainField1:testMainField1];
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg any]]);
[testOp start];
+// OCMStub([testFileManager fileNeedsUpload:[OCMArg any]]).andReturn(YES);
OCMVerifyAllWithDelay(testFileManager, 0.5);
NSArray<SDLArtwork *> *testArtworkUploads = @[buttonWithTextAndImage2.states[1].artwork, buttonWithTextAndImage2.states[2].artwork];
OCMExpect([testFileManager uploadArtworks:testArtworkUploads progressHandler:[OCMArg invokeBlock] completionHandler:[OCMArg invokeBlock]]);
+// OCMExpect([testFileManager fileNeedsUpload:[OCMArg any]]);
[testConnectionManager respondToLastRequestWithResponse:successResponse];
OCMVerifyAllWithDelay(testFileManager, 0.5);
@@ -461,6 +482,7 @@ describe(@"a soft button replace operation", ^{
context(@"When a response is received to the upload", ^{
beforeEach(^{
+ OCMStub([testFileManager fileNeedsUpload:[OCMArg isNotNil]]).andReturn(YES);
OCMExpect([testFileManager uploadArtworks:[OCMArg isNotNil] progressHandler:[OCMArg invokeBlock] completionHandler:[OCMArg invokeBlock]]);
testSoftButtonObjects = @[buttonWithTextAndImage];