diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2016-06-17 16:59:09 -0700 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2016-06-17 16:59:09 -0700 |
commit | ef754ee369590188d6f3070d8e443fe96995cdbe (patch) | |
tree | 05adb1df33f77022b02f98b3cfa3d7e894657b32 | |
parent | 4564749f9cd9085c73dc0e853babca1c8aa31456 (diff) | |
download | sdl_ios-ef754ee369590188d6f3070d8e443fe96995cdbe.tar.gz |
Added dispatch_timer spec tests.
-rw-r--r-- | SmartDeviceLinkTests/SDLTouchManagerSpec.m | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/SmartDeviceLinkTests/SDLTouchManagerSpec.m b/SmartDeviceLinkTests/SDLTouchManagerSpec.m index 6a24d0cc8..4052e6e58 100644 --- a/SmartDeviceLinkTests/SDLTouchManagerSpec.m +++ b/SmartDeviceLinkTests/SDLTouchManagerSpec.m @@ -15,6 +15,7 @@ #import "CGPoint_Util.h" #import "SDLTouch.h" #import "SDLPinchGesture.h" +#import "dispatch_timer.h" QuickSpecBegin(SDLTouchManagerSpec) @@ -290,4 +291,32 @@ describe(@"SDLPinchGesture Tests", ^{ }); }); +describe(@"dispatch_timer Tests", ^{ + context(@"Creating", ^{ + it(@"should be successful within specified time", ^{ + waitUntilTimeout(4, ^(void (^done)(void)) { + __block double currentTime = [[NSDate date] timeIntervalSince1970]; + dispatch_create_timer(2.5, false, ^{ + double difference = [[NSDate date] timeIntervalSince1970] - currentTime; + expect(@(difference)).to(beCloseTo(@(2.5)).within(0.1)); + done(); + }); + }); + }); + + it(@"should be cancellable and not fire", ^{ + __block dispatch_source_t timer; + waitUntilTimeout(2, ^(void (^done)(void)) { + timer = dispatch_create_timer(2.5, false, ^{ + fail(); + }); + [NSThread sleepForTimeInterval:0.5]; + dispatch_stop_timer(timer); + done(); + }); + expect(@(dispatch_source_testcancel(timer))).to(beGreaterThan(@(0))); + }); + }); +}); + QuickSpecEnd |