diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2020-05-06 09:14:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-06 09:14:54 -0400 |
commit | 546c6b93e21237562a897163c05e9ed355407ced (patch) | |
tree | 78ebd76cea6b8493bf4910d34d9952691dc211bc | |
parent | 8a962e68c32c476e8ba20b57e0529c3c0607103e (diff) | |
parent | cdfd791824ca7d8a4b619de79f98f234a8b4b2e7 (diff) | |
download | sdl_ios-546c6b93e21237562a897163c05e9ed355407ced.tar.gz |
Merge pull request #1649 from smartdevicelink/bugfix/issue-1635-buttonpress-initializer
Fixed SDLButtonPress initializer missing mandatory parameter
-rw-r--r-- | SmartDeviceLink/SDLButtonPress.h | 16 | ||||
-rw-r--r-- | SmartDeviceLink/SDLButtonPress.m | 14 | ||||
-rw-r--r-- | SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLButtonPressSpec.m | 22 |
3 files changed, 49 insertions, 3 deletions
diff --git a/SmartDeviceLink/SDLButtonPress.h b/SmartDeviceLink/SDLButtonPress.h index 56b9bcadd..c5769ca6d 100644 --- a/SmartDeviceLink/SDLButtonPress.h +++ b/SmartDeviceLink/SDLButtonPress.h @@ -24,7 +24,7 @@ Constructs a newly allocated SDLButtonPress object with the given parameters @return An instance of the SDLButtonPress class. */ -- (instancetype)initWithButtonName:(SDLButtonName)buttonName moduleType:(SDLModuleType)moduleType __deprecated_msg(("Use initWithButtonName:moduleType:moduleId: instead"));; +- (instancetype)initWithButtonName:(SDLButtonName)buttonName moduleType:(SDLModuleType)moduleType __deprecated_msg(("Use initWithButtonName:moduleType:moduleId:buttonPressMode: instead"));; /** Constructs a newly allocated SDLButtonPress object with the given parameters @@ -35,7 +35,19 @@ Constructs a newly allocated SDLButtonPress object with the given parameters @return An instance of the SDLButtonPress class. */ -- (instancetype)initWithButtonName:(SDLButtonName)buttonName moduleType:(SDLModuleType)moduleType moduleId:(nullable NSString *)moduleId; +- (instancetype)initWithButtonName:(SDLButtonName)buttonName moduleType:(SDLModuleType)moduleType moduleId:(nullable NSString *)moduleId __deprecated_msg(("Use initWithButtonName:moduleType:moduleId:buttonPressMode: instead"));; + +/** +Constructs a newly allocated SDLButtonPress object with the given parameters + +@param buttonName the name of the button +@param moduleType the module where the button should be pressed +@param moduleId the id of the module +@param buttonPressMode indicates LONG or SHORT button press event + +@return An instance of the SDLButtonPress class. +*/ +- (instancetype)initWithButtonName:(SDLButtonName)buttonName moduleType:(SDLModuleType)moduleType moduleId:(nullable NSString *)moduleId buttonPressMode:(SDLButtonPressMode)buttonPressMode; /** * The module where the button should be pressed. diff --git a/SmartDeviceLink/SDLButtonPress.m b/SmartDeviceLink/SDLButtonPress.m index 4f215c206..419f0d7f6 100644 --- a/SmartDeviceLink/SDLButtonPress.m +++ b/SmartDeviceLink/SDLButtonPress.m @@ -37,10 +37,24 @@ NS_ASSUME_NONNULL_BEGIN if (!self) { return nil; } + + self.buttonName = buttonName; + self.moduleType = moduleType; + self.moduleId = moduleId; + + return self; +} + +- (instancetype)initWithButtonName:(SDLButtonName)buttonName moduleType:(SDLModuleType)moduleType moduleId:(nullable NSString *)moduleId buttonPressMode:(SDLButtonPressMode)buttonPressMode { + self = [self init]; + if (!self) { + return nil; + } self.buttonName = buttonName; self.moduleType = moduleType; self.moduleId = moduleId; + self.buttonPressMode = buttonPressMode; return self; } diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLButtonPressSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLButtonPressSpec.m index 23f2b4916..d9a49d20c 100644 --- a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLButtonPressSpec.m +++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLButtonPressSpec.m @@ -53,12 +53,32 @@ describe(@"Getter/Setter Tests", ^ { expect(testRequest.buttonPressMode).to(equal(SDLButtonPressModeShort)); }); - it(@"Should get correctly using initializer", ^ { + it(@"Should get correctly when initialized with initWithButtonName:moduleType:", ^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + SDLButtonPress *testRequest = [[SDLButtonPress alloc] initWithButtonName:SDLButtonNameAC moduleType:SDLModuleTypeClimate]; +#pragma clang diagnostic pop + expect(testRequest.buttonName).to(equal(SDLButtonNameAC)); + expect(testRequest.moduleType).to(equal(SDLModuleTypeClimate)); + }); + + it(@"Should get correctly when initialized with initWithButtonName:moduleType:moduleId:", ^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" SDLButtonPress *testRequest = [[SDLButtonPress alloc] initWithButtonName:SDLButtonNameAC moduleType:SDLModuleTypeClimate moduleId:@"123"]; +#pragma clang diagnostic pop + expect(testRequest.buttonName).to(equal(SDLButtonNameAC)); + expect(testRequest.moduleType).to(equal(SDLModuleTypeClimate)); + expect(testRequest.moduleId).to(equal(@"123")); + }); + + it(@"Should get correctly when initialized with initWithButtonName:moduleType:moduleId:buttonPressMode:", ^ { + SDLButtonPress *testRequest = [[SDLButtonPress alloc] initWithButtonName:SDLButtonNameAC moduleType:SDLModuleTypeClimate moduleId:@"123" buttonPressMode:SDLButtonPressModeShort]; expect(testRequest.buttonName).to(equal(SDLButtonNameAC)); expect(testRequest.moduleType).to(equal(SDLModuleTypeClimate)); expect(testRequest.moduleId).to(equal(@"123")); + expect(testRequest.buttonPressMode).to(equal(SDLButtonPressModeShort)); }); it(@"Should return nil if not set", ^ { |