diff options
author | NicoleYarroch <nicole@livio.io> | 2020-04-14 08:22:48 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2020-04-14 08:22:48 -0400 |
commit | 0ad8f49e7320ce7058058310cf386c5ac5ec17fb (patch) | |
tree | d844a32cefdcf16cf849de66c25f5fdefd94064c | |
parent | 6bc0d8cb7984980d568e1a6c82e0bb8c3af77bed (diff) | |
download | sdl_ios-0ad8f49e7320ce7058058310cf386c5ac5ec17fb.tar.gz |
Added tests
-rw-r--r-- | SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m index 1964f189a..1ca8a23c7 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m @@ -64,7 +64,7 @@ static const int TCPPortUnspecified = -1; @property (strong, nonatomic, nullable) SDLHMILevel currentHMILevel; @property (strong, nonatomic) SDLBackgroundTaskManager *backgroundTaskManager; -- (nullable void (^)(void))sdl_backgroundTaskEndedHandler; +- (nullable BOOL (^)(void))sdl_backgroundTaskEndedHandler; @end @@ -1229,20 +1229,22 @@ describe(@"the secondary transport manager ", ^{ [SDLSecondaryTransportManager swapGetInactiveAppStateMethod]; }); - it(@"should stop the TCP transport if the app is still in the background", ^{ + it(@"should stop the TCP transport if the app is still in the background and perform cleanup before ending the background task", ^{ [manager.stateMachine setToState:SDLSecondaryTransportStateRegistered fromOldState:nil callEnterTransition:NO]; - manager.sdl_backgroundTaskEndedHandler(); + BOOL waitForCleanupToFinish = manager.sdl_backgroundTaskEndedHandler(); expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); + expect(waitForCleanupToFinish).to(beTrue()); }); - it(@"should ignore the notification if the manager has stopped before the background task ended", ^{ + it(@"should ignore the notification if the manager has stopped before the background task ended and immediately end the background task", ^{ [manager.stateMachine setToState:SDLSecondaryTransportStateStopped fromOldState:nil callEnterTransition:NO]; - manager.sdl_backgroundTaskEndedHandler(); + BOOL waitForCleanupToFinish = manager.sdl_backgroundTaskEndedHandler(); expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); + expect(waitForCleanupToFinish).to(beFalse()); }); afterEach(^{ @@ -1251,12 +1253,13 @@ describe(@"the secondary transport manager ", ^{ }); context(@"If the app is has entered the foreground", ^{ - it(@"should ignore the notification if the app has returned to the foreground", ^{ + it(@"should ignore the notification if the app has returned to the foreground and immediately end the background task", ^{ [manager.stateMachine setToState:SDLSecondaryTransportStateRegistered fromOldState:nil callEnterTransition:NO]; - manager.sdl_backgroundTaskEndedHandler(); + BOOL waitForCleanupToFinish = manager.sdl_backgroundTaskEndedHandler(); expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateRegistered)); + expect(waitForCleanupToFinish).to(beFalse()); }); }); }); |