From 445fdce655abf8721e2749250d75d482a7045fed Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Thu, 6 Jan 2022 11:49:13 -0500 Subject: [PATCH 1/5] Fix initializing soft button object error states * Fix tests * Update soft button state initialization to fail in RELEASE in undefined states too --- SmartDeviceLink/public/SDLSoftButtonObject.m | 14 +++++++++++--- SmartDeviceLink/public/SDLSoftButtonState.m | 2 ++ SmartDeviceLinkTests/SDLSoftButtonObjectSpec.m | 14 +++----------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/SmartDeviceLink/public/SDLSoftButtonObject.m b/SmartDeviceLink/public/SDLSoftButtonObject.m index adb153e1a..809fa3a03 100644 --- a/SmartDeviceLink/public/SDLSoftButtonObject.m +++ b/SmartDeviceLink/public/SDLSoftButtonObject.m @@ -36,11 +36,19 @@ - (instancetype)initWithName:(NSString *)name states:(NSArray Date: Fri, 7 Jan 2022 10:58:19 -0500 Subject: [PATCH 2/5] Remove pointless comment --- SmartDeviceLink/public/SDLSoftButtonObject.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/SmartDeviceLink/public/SDLSoftButtonObject.m b/SmartDeviceLink/public/SDLSoftButtonObject.m index 809fa3a03..9bcdfac65 100644 --- a/SmartDeviceLink/public/SDLSoftButtonObject.m +++ b/SmartDeviceLink/public/SDLSoftButtonObject.m @@ -42,8 +42,6 @@ - (instancetype)initWithName:(NSString *)name states:(NSArray Date: Tue, 11 Jan 2022 14:09:39 -0500 Subject: [PATCH 3/5] Add error logs --- SmartDeviceLink/public/SDLSoftButtonObject.m | 14 ++++++++++---- SmartDeviceLink/public/SDLSoftButtonState.m | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/SmartDeviceLink/public/SDLSoftButtonObject.m b/SmartDeviceLink/public/SDLSoftButtonObject.m index 9bcdfac65..9ab2a3217 100644 --- a/SmartDeviceLink/public/SDLSoftButtonObject.m +++ b/SmartDeviceLink/public/SDLSoftButtonObject.m @@ -42,10 +42,16 @@ - (instancetype)initWithName:(NSString *)name states:(NSArray *)states { ++ (BOOL)sdl_hasTwoStatesOfSameName:(NSArray *)states { for (NSUInteger i = 0; i < states.count; i++) { NSString *stateName = states[i].name; for (NSUInteger j = (i + 1); j < states.count; j++) { diff --git a/SmartDeviceLink/public/SDLSoftButtonState.m b/SmartDeviceLink/public/SDLSoftButtonState.m index e433adfe8..63b30c69c 100644 --- a/SmartDeviceLink/public/SDLSoftButtonState.m +++ b/SmartDeviceLink/public/SDLSoftButtonState.m @@ -33,7 +33,10 @@ @implementation SDLSoftButtonState - (instancetype)initWithStateName:(NSString *)stateName text:(nullable NSString *)text image:(nullable UIImage *)image { NSParameterAssert((text != nil) || (image != nil)); - if ((text == nil) && (image == nil)) { return nil; } + if ((text == nil) && (image == nil)) { + SDLLogE(@"Error creating soft button state: the state requires either text or an image, or both. StateName: %@", stateName); + return nil; + } SDLArtwork *artwork = [[SDLArtwork alloc] initWithImage:image persistent:YES asImageFormat:SDLArtworkImageFormatPNG]; return [self initWithStateName:stateName text:text artwork:artwork]; From bd8041dacc0983fef3946c2bed169b55a62669b1 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 12 Jan 2022 15:40:21 -0500 Subject: [PATCH 4/5] Fix missing log --- SmartDeviceLink/public/SDLSoftButtonState.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SmartDeviceLink/public/SDLSoftButtonState.m b/SmartDeviceLink/public/SDLSoftButtonState.m index 63b30c69c..fdbbad09d 100644 --- a/SmartDeviceLink/public/SDLSoftButtonState.m +++ b/SmartDeviceLink/public/SDLSoftButtonState.m @@ -47,7 +47,10 @@ - (instancetype)initWithStateName:(NSString *)stateName text:(nullable NSString if (!self) { return nil; } NSParameterAssert((text != nil) || (artwork != nil)); - if ((text == nil) && (artwork == nil)) { return nil; } + if ((text == nil) && (artwork == nil)) { + SDLLogE(@"Error creating soft button state: the state requires either text or an image, or both. StateName: %@", stateName); + return nil; + } _name = stateName; _text = text; From d14d3ddf02356f4a31954f177d0896e916f0e389 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Tue, 1 Feb 2022 11:11:43 -0500 Subject: [PATCH 5/5] Add a break --- SmartDeviceLink/public/SDLSoftButtonObject.m | 1 + 1 file changed, 1 insertion(+) diff --git a/SmartDeviceLink/public/SDLSoftButtonObject.m b/SmartDeviceLink/public/SDLSoftButtonObject.m index 9ab2a3217..9b6251bd6 100644 --- a/SmartDeviceLink/public/SDLSoftButtonObject.m +++ b/SmartDeviceLink/public/SDLSoftButtonObject.m @@ -40,6 +40,7 @@ - (instancetype)initWithName:(NSString *)name states:(NSArray