diff options
author | Frank Elias <francois.elias@livio.io> | 2020-11-23 14:22:57 -0500 |
---|---|---|
committer | Frank Elias <francois.elias@livio.io> | 2020-11-23 14:22:57 -0500 |
commit | 38e42ef7092edf96038adf2e96da1abeb35db322 (patch) | |
tree | d19ceceadf4e65f46999905650546a42728d003d | |
parent | 5c2bb0fd4f16b15ad8b6c805927146851388713a (diff) | |
download | sdl_ios-38e42ef7092edf96038adf2e96da1abeb35db322.tar.gz |
Comments review
8 files changed, 21 insertions, 32 deletions
diff --git a/SmartDeviceLink/private/SDLMenuManager.m b/SmartDeviceLink/private/SDLMenuManager.m index c68c3222f..e5fe5c4bd 100644 --- a/SmartDeviceLink/private/SDLMenuManager.m +++ b/SmartDeviceLink/private/SDLMenuManager.m @@ -552,22 +552,18 @@ UInt32 const MenuCellIdMin = 1; } - (BOOL)sdl_artworkNeedsUpload:(SDLArtwork *)artwork { - if (artwork != nil) { - if (artwork.isStaticIcon) { - return NO; - } else { - return (artwork.overwrite || (self.fileManager != nil && ![self.fileManager hasUploadedFile:artwork])); - } + if (artwork != nil && !artwork.isStaticIcon) { + return (artwork.overwrite || (self.fileManager != nil && ![self.fileManager hasUploadedFile:artwork])); } + return NO; } -- (BOOL) sdl_allArtworksUploaded:(NSArray<SDLMenuCell *> *)cells { +- (BOOL) sdl_areAllCellArtworksUploaded:(NSArray<SDLMenuCell *> *)cells { for (SDLMenuCell *cell in cells) { if (![self sdl_artworkUploaded:cell.icon]) { return NO; - } - if (cell.subCells != nil && (cell.subCells.count) > 0) { + } else if (cell.subCells != nil && (cell.subCells.count) > 0) { return [self sdl_allArtworksUploaded:cell.subCells]; } } @@ -575,7 +571,7 @@ UInt32 const MenuCellIdMin = 1; return YES; } -- (BOOL) sdl_artworkUploaded:(SDLArtwork *)artwork { +- (BOOL) sdl_isArtworkUploaded:(nullable SDLArtwork *)artwork { if (artwork != nil) { return artwork.isStaticIcon || (self.fileManager != nil && [self.fileManager hasUploadedFile:artwork]); } diff --git a/SmartDeviceLink/private/SDLPreloadChoicesOperation.m b/SmartDeviceLink/private/SDLPreloadChoicesOperation.m index d84cc1acf..e9dd89156 100644 --- a/SmartDeviceLink/private/SDLPreloadChoicesOperation.m +++ b/SmartDeviceLink/private/SDLPreloadChoicesOperation.m @@ -115,10 +115,8 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)sdl_artworkNeedsUpload:(SDLArtwork *)artwork { if (artwork != nil) { - if (artwork.isStaticIcon) { - return NO; - } else { - return artwork.overwrite || (self.fileManager != nil && ![self.fileManager hasUploadedFile:artwork]); + if (artwork != nil && !artwork.isStaticIcon) { + return (artwork.overwrite || (self.fileManager != nil && ![self.fileManager hasUploadedFile:artwork])); } } return NO; diff --git a/SmartDeviceLink/private/SDLSoftButtonReplaceOperation.m b/SmartDeviceLink/private/SDLSoftButtonReplaceOperation.m index f702efb43..42bc772dc 100644 --- a/SmartDeviceLink/private/SDLSoftButtonReplaceOperation.m +++ b/SmartDeviceLink/private/SDLSoftButtonReplaceOperation.m @@ -228,13 +228,10 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Images - (BOOL)sdl_artworkNeedsUpload:(SDLArtwork *)artwork { - if (artwork != nil && self.softButtonCapabilities.imageSupported) { - if (artwork.isStaticIcon) { - return NO; - } else { - return artwork.overwrite || (self.fileManager != nil && ![self.fileManager hasUploadedFile:artwork]); - } + if (artwork != nil && !artwork.isStaticIcon) { + return (artwork.overwrite || (self.fileManager != nil && ![self.fileManager hasUploadedFile:artwork])); } + return NO; } diff --git a/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m b/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m index d50e7fddf..a7df9fb63 100644 --- a/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m +++ b/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m @@ -516,20 +516,18 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Should Update - (BOOL)sdl_artworkNeedsUpload:(SDLArtwork *)artwork { - if (artwork != nil) { - if (artwork.isStaticIcon) { - return NO; - } else { - return (artwork.overwrite || (![self.fileManager hasUploadedFile:artwork])); - } + if (artwork != nil && !artwork.isStaticIcon) { + return (artwork.overwrite || (self.fileManager != nil && ![self.fileManager hasUploadedFile:artwork])); } + return NO; } -- (BOOL) sdl_artworkUploaded:(SDLArtwork *)artwork { +- (BOOL)sdl_artworkIsUploaded:(nullable SDLArtwork *)artwork { if (artwork != nil) { return artwork.isStaticIcon || (self.fileManager != nil && [self.fileManager hasUploadedFile:artwork]); } + return YES; } @@ -537,7 +535,7 @@ NS_ASSUME_NONNULL_BEGIN // If the template is updating, we don't yet know it's capabilities. Just assume the template supports the primary image. BOOL templateSupportsPrimaryArtwork = [self.currentCapabilities hasImageFieldOfName:SDLImageFieldNameGraphic] || [self sdl_shouldUpdateTemplateConfig]; BOOL graphicNameMatchesExisting = [self.currentScreenData.primaryGraphic.name isEqualToString:self.updatedState.primaryGraphic.name]; - BOOL shouldOverwriteGraphic = self.updatedState.primaryGraphic != nil && self.updatedState.primaryGraphic.overwrite; + BOOL shouldOverwriteGraphic = self.updatedState.primaryGraphic.overwrite; BOOL graphicExists = (self.updatedState.primaryGraphic != nil); return (templateSupportsPrimaryArtwork && (shouldOverwriteGraphic || !graphicNameMatchesExisting) && graphicExists); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m index e4bdf9e54..c5b633772 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuManagerSpec.m @@ -234,7 +234,7 @@ describe(@"menu manager", ^{ OCMReject([mockFileManager uploadArtworks:[OCMArg any] completionHandler:[OCMArg any]]); }); - it(@"should properly override an image cell", ^{ + it(@"should properly overwrite an image cell", ^{ 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 c6b8fa9bc..a5f161c0c 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadChoicesOperationSpec.m @@ -148,7 +148,7 @@ describe(@"a preload choices operation", ^{ expect(@(testOp.currentState)).to(equal(SDLPreloadChoicesOperationStatePreloadingChoices)); }); - it(@"should properly override artwork", ^{ + it(@"should properly overwrite artwork", ^{ cell1Art2.overwrite = YES; SDLChoiceCell *cell1WithArt = [[SDLChoiceCell alloc] initWithText:@"Cell1" artwork:cell1Art2 voiceCommands:nil]; diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m index 5b3179df0..1afe0a736 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLTextAndGraphicUpdateOperationSpec.m @@ -835,7 +835,7 @@ describe(@"the text and graphic operation", ^{ OCMReject([mockFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]); }); - it(@"should properly override artwork", ^{ + it(@"should properly overwrite artwork", ^{ SDLArtwork *testArtwork3 = [[SDLArtwork alloc] initWithData:[@"Test data 3" dataUsingEncoding:NSUTF8StringEncoding] name:testArtworkName fileExtension:@"png" persistent:NO]; testArtwork3.overwrite = YES; diff --git a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m index 28911ad57..54bfc8e52 100644 --- a/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m +++ b/SmartDeviceLinkTests/SDLSoftButtonReplaceOperationSpec.m @@ -299,7 +299,7 @@ describe(@"a soft button replace operation", ^{ expect(sentRequests.firstObject.softButtons.lastObject.type).to(equal(SDLSoftButtonTypeBoth)); }); - it(@"should properly override artwork", ^{ + it(@"should properly overwrite artwork", ^{ OCMExpect([testFileManager uploadArtworks:[OCMArg any] progressHandler:[OCMArg any] completionHandler:[OCMArg any]]); object2State1 = [[SDLSoftButtonState alloc] initWithStateName:object2State1Name text:object2State1Text artwork:object2State11Art]; |