diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2017-03-03 10:23:21 -0500 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2017-03-03 10:23:21 -0500 |
commit | 3847dcaf3edd5d4ef0c45ea02166e182be562b52 (patch) | |
tree | dcdb633251e3222c89239fb2a19cd85f1d58b637 | |
parent | dc15b45f58c65b6d5d961062c5374997f6747689 (diff) | |
download | sdl_ios-3847dcaf3edd5d4ef0c45ea02166e182be562b52.tar.gz |
Fix handler updates in example app and unit tests
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLResponseDispatcherSpec.m | 14 | ||||
-rw-r--r-- | SmartDeviceLink_Example/Classes/ProxyManager.m | 12 |
2 files changed, 14 insertions, 12 deletions
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLResponseDispatcherSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLResponseDispatcherSpec.m index 3d5d2ef76..be5c088dd 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLResponseDispatcherSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLResponseDispatcherSpec.m @@ -123,7 +123,7 @@ describe(@"a response dispatcher", ^{ beforeEach(^{ numTimesHandlerCalled = 0; - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) { + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { numTimesHandlerCalled++; }]; testShow.softButtons = [@[testSoftButton1] mutableCopy]; @@ -190,7 +190,7 @@ describe(@"a response dispatcher", ^{ context(@"with a malformed soft button", ^{ beforeEach(^{ - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) {}]; + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:nil]; }); it(@"should throw an exception if there's no button id", ^{ @@ -340,7 +340,7 @@ describe(@"a response dispatcher", ^{ testSubscribeCorrelationId = @42; numTimesHandlerCalled = 0; - testSubscribeButton = [[SDLSubscribeButton alloc] initWithButtonName:testButtonName handler:^(__kindof SDLRPCNotification * _Nonnull notification) { + testSubscribeButton = [[SDLSubscribeButton alloc] initWithButtonName:testButtonName handler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { numTimesHandlerCalled++; }]; testSubscribeButton.correlationID = testSubscribeCorrelationId; @@ -463,7 +463,7 @@ describe(@"a response dispatcher", ^{ beforeEach(^{ numTimesHandlerCalled = 0; - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) { + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { numTimesHandlerCalled++; }]; @@ -530,7 +530,7 @@ describe(@"a response dispatcher", ^{ context(@"with a malformed soft button", ^{ beforeEach(^{ - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) {}]; + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:nil]; }); it(@"should throw an exception if there's no button id", ^{ @@ -568,7 +568,7 @@ describe(@"a response dispatcher", ^{ beforeEach(^{ numTimesHandlerCalled = 0; - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) { + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { numTimesHandlerCalled++; }]; @@ -635,7 +635,7 @@ describe(@"a response dispatcher", ^{ context(@"with a malformed soft button", ^{ beforeEach(^{ - testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:^(__kindof SDLRPCNotification * _Nonnull notification) {}]; + testSoftButton1 = [[SDLSoftButton alloc] initWithType:SDLSoftButtonTypeText text:@"test" image:nil highlighted:NO buttonId:1 systemAction:SDLSystemActionDefaultAction handler:nil]; }); it(@"should throw an exception if there's no button id", ^{ diff --git a/SmartDeviceLink_Example/Classes/ProxyManager.m b/SmartDeviceLink_Example/Classes/ProxyManager.m index d0fef72d1..6c728f830 100644 --- a/SmartDeviceLink_Example/Classes/ProxyManager.m +++ b/SmartDeviceLink_Example/Classes/ProxyManager.m @@ -272,12 +272,14 @@ NS_ASSUME_NONNULL_BEGIN } + (SDLSoftButton *)pointingSoftButtonWithManager:(SDLManager *)manager { - SDLSoftButton* softButton = [[SDLSoftButton alloc] initWithHandler:^(__kindof SDLRPCNotification *notification) { - if ([notification isKindOfClass:[SDLOnButtonPress class]]) { - SDLAlert* alert = [[SDLAlert alloc] init]; - alert.alertText1 = @"You pushed the button!"; - [manager sendRequest:alert]; + SDLSoftButton* softButton = [[SDLSoftButton alloc] initWithHandler:^(SDLOnButtonPress * _Nullable buttonPressNotification, SDLOnButtonEvent * _Nullable buttonEventNotification) { + if (buttonPressNotification == nil) { + return; } + + SDLAlert* alert = [[SDLAlert alloc] init]; + alert.alertText1 = @"You pushed the button!"; + [manager sendRequest:alert]; }]; softButton.text = @"Press"; softButton.softButtonID = @100; |