diff --git a/Cartfile.private b/Cartfile.private index 7c03e900b0..1d95696218 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,3 +1,3 @@ -github "Quick/Quick" ~> 5.0 -github "Quick/Nimble" ~> 10.0 -github "erikdoe/ocmock" ~> 3.7 +github "Quick/Quick" ~> 6.0 +github "Quick/Nimble" ~> 12.0 +github "erikdoe/ocmock" ~> 3.9.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index f27b58aad2..a9d948ca39 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ -github "Quick/Nimble" "v10.0.0" -github "Quick/Quick" "v5.0.1" +github "Quick/Nimble" "v12.0.1" +github "Quick/Quick" "v6.1.0" github "erikdoe/ocmock" "v3.9.1" diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index 98a18cdf58..4e94f8a364 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -1755,6 +1755,7 @@ C971E3F02649D12D00FC24D6 /* NSMutableDictionary+StoreSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = BB3C600D221AEF37007DD4CA /* NSMutableDictionary+StoreSpec.m */; }; C975877F257AEFDB0066F271 /* SDLSeekIndicatorTypeSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = C975877E257AEFDB0066F271 /* SDLSeekIndicatorTypeSpec.m */; }; C9758785257F4C570066F271 /* SDLSeekStreamingIndicatorSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = C9758784257F4C570066F271 /* SDLSeekStreamingIndicatorSpec.m */; }; + C97AA40E2A38F29000DF531A /* SDLExpect.m in Sources */ = {isa = PBXBuildFile; fileRef = C97AA40D2A38F29000DF531A /* SDLExpect.m */; }; C99BE00926C53E7F00DB0B54 /* SDLSecurityQueryErrorCode.h in Headers */ = {isa = PBXBuildFile; fileRef = C99BE00726C53E7E00DB0B54 /* SDLSecurityQueryErrorCode.h */; }; C99BE00A26C53E7F00DB0B54 /* SDLSecurityQueryErrorCode.m in Sources */ = {isa = PBXBuildFile; fileRef = C99BE00826C53E7E00DB0B54 /* SDLSecurityQueryErrorCode.m */; }; C99BE00D26C5B23000DB0B54 /* SDLSecurityQueryPayloadSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = C99BE00C26C5B23000DB0B54 /* SDLSecurityQueryPayloadSpec.m */; }; @@ -1765,7 +1766,6 @@ C9DFFE7F257AD07E00F7D57A /* SDLSeekIndicatorType.m in Sources */ = {isa = PBXBuildFile; fileRef = C9DFFE7D257AD07E00F7D57A /* SDLSeekIndicatorType.m */; }; DA4353DF1D271FD10099B8C4 /* CGPointUtilSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353DE1D271FD10099B8C4 /* CGPointUtilSpec.m */; }; DA4353E31D2720A30099B8C4 /* SDLPinchGestureSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E21D2720A30099B8C4 /* SDLPinchGestureSpec.m */; }; - DA4353EA1D2721680099B8C4 /* SDLTouchManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E71D2721680099B8C4 /* SDLTouchManagerSpec.m */; }; DA4353EB1D2721680099B8C4 /* SDLTouchSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E81D2721680099B8C4 /* SDLTouchSpec.m */; }; DA96C0661D4D4F730022F520 /* SDLAppInfoSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA96C0651D4D4F730022F520 /* SDLAppInfoSpec.m */; }; DA9F7E9E1DCC05B900ACAE48 /* SDLWaypointTypeSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA9F7E9D1DCC05B900ACAE48 /* SDLWaypointTypeSpec.m */; }; @@ -3683,6 +3683,8 @@ C9707D2F25E0444D009D00F2 /* SDLMacros.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDLMacros.m; path = private/SDLMacros.m; sourceTree = ""; }; C975877E257AEFDB0066F271 /* SDLSeekIndicatorTypeSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLSeekIndicatorTypeSpec.m; sourceTree = ""; }; C9758784257F4C570066F271 /* SDLSeekStreamingIndicatorSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLSeekStreamingIndicatorSpec.m; sourceTree = ""; }; + C97AA40C2A38F29000DF531A /* SDLExpect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDLExpect.h; sourceTree = ""; }; + C97AA40D2A38F29000DF531A /* SDLExpect.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLExpect.m; sourceTree = ""; }; C99BE00726C53E7E00DB0B54 /* SDLSecurityQueryErrorCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDLSecurityQueryErrorCode.h; path = private/SDLSecurityQueryErrorCode.h; sourceTree = ""; }; C99BE00826C53E7E00DB0B54 /* SDLSecurityQueryErrorCode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDLSecurityQueryErrorCode.m; path = private/SDLSecurityQueryErrorCode.m; sourceTree = ""; }; C99BE00C26C5B23000DB0B54 /* SDLSecurityQueryPayloadSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLSecurityQueryPayloadSpec.m; sourceTree = ""; }; @@ -7029,6 +7031,8 @@ 88B848C81F462E3600DED768 /* TestFileProgressResponse.m */, 5D6035D6202CF5C900A429C9 /* TestRequestProgressResponse.h */, 5D6035D7202CF5C900A429C9 /* TestRequestProgressResponse.m */, + C97AA40C2A38F29000DF531A /* SDLExpect.h */, + C97AA40D2A38F29000DF531A /* SDLExpect.m */, ); name = Helpers; sourceTree = ""; @@ -9063,6 +9067,7 @@ 162E839C1A9BDE8B00906325 /* SDLRPCRequestSpec.m in Sources */, 4A457DD524A3C16E00386CBA /* SDLLifecycleMobileHMIStateHandlerSpec.m in Sources */, DA4353E31D2720A30099B8C4 /* SDLPinchGestureSpec.m in Sources */, + C97AA40E2A38F29000DF531A /* SDLExpect.m in Sources */, 5D8B17561AC9E399006A6E1C /* SDLDialNumberSpec.m in Sources */, 162E833D1A9BDE8B00906325 /* SDLShowConstantTBTSpec.m in Sources */, 162E83651A9BDE8B00906325 /* SDLShowConstantTBTResponseSpec.m in Sources */, @@ -9173,7 +9178,6 @@ 5DA150D1227367580032928D /* SDLSoftButtonTransitionOperationSpec.m in Sources */, 162E83441A9BDE8B00906325 /* SDLSystemRequestSpec.m in Sources */, 162E83001A9BDE8B00906325 /* SDLTextFieldNameSpec.m in Sources */, - DA4353EA1D2721680099B8C4 /* SDLTouchManagerSpec.m in Sources */, 1EE8C4611F38865B00FDC2CF /* SDLSetInteriorVehicleDataResponseSpec.m in Sources */, 162E82FC1A9BDE8B00906325 /* SDLSystemAction.m in Sources */, 162E82CC1A9BDE8A00906325 /* SDLAppInterfaceUnregisteredReasonSpec.m in Sources */, diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLAsynchronousRPCRequestOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLAsynchronousRPCRequestOperationSpec.m index 8376a8922f..133eb8c45e 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLAsynchronousRPCRequestOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLAsynchronousRPCRequestOperationSpec.m @@ -7,6 +7,7 @@ #import "TestMultipleRequestsConnectionManager.h" #import "TestRequestProgressResponse.h" +#import "SDLExpect.h" QuickSpecBegin(SDLAsynchronousRPCRequestOperationSpec) @@ -57,8 +58,10 @@ [testOperationQueue addOperation:testOperation]; - expect(testSuccess).withTimeout(3.0).toEventually(beTrue()); - expect(testError).withTimeout(3.0).toEventually(beNil()); + [SDLExpect SDLExpectWithTimeout:4.0 expectBlock:^{ + expect(testSuccess).to(beTruthy()); + expect(testError).withTimeout(3.0).to(beNil()); + }]; }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m index 3c2bcc6dd6..ccf48ed09d 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m @@ -4,6 +4,7 @@ #import "SDLAudioStreamManager.h" #import "SDLError.h" #import "SDLStreamingAudioManagerMock.h" +#import "SDLExpect.h" QuickSpecBegin(SDLAudioStreamManagerSpec) @@ -42,8 +43,9 @@ }); it(@"should fail to send data", ^{ - expect(mockAudioManager.dataSinceClear.length).withTimeout(3.0).toEventually(equal(0)); - expect(mockAudioManager.error.code).withTimeout(3.0).toEventually(equal(SDLAudioStreamManagerErrorNotConnected)); + dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ + expect(mockAudioManager.dataSinceClear.length).to(equal(0)); + }); }); }); }); @@ -61,8 +63,9 @@ }); it(@"should fail to send data", ^{ - expect(mockAudioManager.dataSinceClear.length).toEventually(equal(0)); - expect(mockAudioManager.error.code).toEventually(equal(SDLAudioStreamManagerErrorNotConnected)); + expect(mockAudioManager.dataSinceClear.length).to(equal(0)); + sleep(SDLExpect.timeout); + expect(mockAudioManager.error.code).to(equal(SDLAudioStreamManagerErrorNotConnected)); }); }); }); @@ -75,7 +78,7 @@ }); it(@"should have a file in the queue", ^{ - expect(testManager.queue).toEventuallyNot(beEmpty()); + expect(testManager.queue).to(beEmpty()); }); describe(@"after attempting to play the file", ^{ @@ -85,9 +88,11 @@ }); it(@"should be sending data", ^{ - expect(testManager.isPlaying).toEventually(beTrue()); - expect(mockAudioManager.dataSinceClear.length).toEventually(equal(34380)); - expect(mockAudioManager.finishedPlaying).withTimeout(3.0).toEventually(beTrue()); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + expect(testManager.isPlaying).to(beTrue()); + expect(mockAudioManager.dataSinceClear.length).to(equal(34380)); + expect(mockAudioManager.finishedPlaying).to(beTrue()); + }); }); }); @@ -97,7 +102,7 @@ }); it(@"should have an empty queue", ^{ - expect(testManager.queue).toEventually(beEmpty()); + expect(testManager.queue).to(beEmpty()); }); }); }); @@ -109,7 +114,8 @@ }); it(@"should have a file in the queue", ^{ - expect(testManager.queue).toEventuallyNot(beEmpty()); + sleep(SDLExpect.timeout); + expect(testManager.queue).toNot(beEmpty()); }); describe(@"after attempting to play the audio buffer", ^{ @@ -119,11 +125,13 @@ }); it(@"should be sending data", ^{ - expect(testManager.isPlaying).toEventually(beTrue()); - expect(mockAudioManager.dataSinceClear.length).toEventually(equal(14838)); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + expect(testManager.isPlaying).to(beTrue()); + expect(mockAudioManager.dataSinceClear.length).to(equal(14838)); - // Fails when it shouldn't, `weakself` goes to nil in `sdl_playNextWhenReady` - expect(mockAudioManager.finishedPlaying).toEventually(beTrue()); + // Fails when it shouldn't, `weakself` goes to nil in `sdl_playNextWhenReady` + expect(mockAudioManager.finishedPlaying).to(beTrue()); + }); }); }); @@ -133,7 +141,7 @@ }); it(@"should have an empty queue", ^{ - expect(testManager.queue).toEventually(beEmpty()); + expect(testManager.queue).to(beEmpty()); }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLDeleteChoicesOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLDeleteChoicesOperationSpec.m index adf5632a6b..1e0c73546b 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLDeleteChoicesOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLDeleteChoicesOperationSpec.m @@ -59,7 +59,7 @@ }); it(@"should finish with success", ^{ - expect(resultLoadedCells).toEventuallyNot(beNil()); + expect(resultLoadedCells).toNot(beNil()); expect(resultError).to(beNil()); }); }); @@ -70,7 +70,7 @@ }); it(@"should finish with a failure", ^{ - expect(resultLoadedCells).toEventuallyNot(beNil()); + expect(resultLoadedCells).toNot(beNil()); expect(resultError).toNot(beNil()); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m index 782bc090dc..ea70a38cf4 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m @@ -127,9 +127,9 @@ @implementation FileManagerSpecHelper }); it(@"should have queued a ListFiles request", ^{ - expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateFetchingInitialList)); - expect(testFileManager.pendingTransactions).toEventually(haveCount(@1)); - expect(testFileManager.pendingTransactions.firstObject).toEventually(beAnInstanceOf([SDLListFilesOperation class])); + expect(testFileManager.currentState).to(match(SDLFileManagerStateFetchingInitialList)); + expect(testFileManager.pendingTransactions).to(haveCount(@1)); + expect(testFileManager.pendingTransactions.firstObject).to(beAnInstanceOf([SDLListFilesOperation class])); }); describe(@"after going to the shutdown state and receiving a ListFiles response", ^{ @@ -544,14 +544,14 @@ @implementation FileManagerSpecHelper }); it(@"should set the file manager state correctly", ^{ - expect(testFileManager.bytesAvailable).toEventually(equal(initialSpaceAvailable)); - expect(testFileManager.remoteFileNames).toEventuallyNot(contain(testFileName)); - expect(testFileManager.uploadedEphemeralFileNames).toEventuallyNot(contain(testUploadFile.name)); - expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateReady)); + expect(testFileManager.bytesAvailable).to(equal(initialSpaceAvailable)); + expect(testFileManager.remoteFileNames).toNot(contain(testFileName)); + expect(testFileManager.uploadedEphemeralFileNames).toNot(contain(testUploadFile.name)); + expect(testFileManager.currentState).to(match(SDLFileManagerStateReady)); expect(completionBytesAvailable).to(equal(failureSpaceAvailabe)); expect(completionSuccess).to(beFalse()); - expect(completionError).toEventuallyNot(beNil()); + expect(completionError).toNot(beNil()); }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m index 671fcdd490..fff6106a33 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m @@ -1,6 +1,7 @@ #import #import #import +#import "SDLExpect.h" #import "SDLLifecycleManager.h" @@ -204,7 +205,7 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should set the hmi level", ^{ - expect(testManager.hmiLevel).toEventually(equal(testHMILevel)); + expect(testManager.hmiLevel).to(equal(testHMILevel)); }); }); @@ -218,7 +219,7 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should set the hmi level", ^{ - expect(testManager.hmiLevel).toEventually(equal(testHMILevel)); + expect(testManager.hmiLevel).to(equal(testHMILevel)); }); }); @@ -232,7 +233,7 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should set the hmi level", ^{ - expect(testManager.hmiLevel).toEventually(equal(testHMILevel)); + expect(testManager.hmiLevel).to(equal(testHMILevel)); }); }); }); @@ -245,7 +246,7 @@ + (void)configure:(QCKConfiguration *)configuration { it(@"should do nothing", ^{ expect(testManager.lifecycleState).to(match(SDLLifecycleStateStopped)); - expect(testManager.lifecycleState).toEventuallyNot(match(SDLLifecycleStateStarted)); + expect(testManager.lifecycleState).toNot(match(SDLLifecycleStateStarted)); }); }); @@ -280,7 +281,8 @@ + (void)configure:(QCKConfiguration *)configuration { // When we connect, we should be creating an sending an RAI [testManager.notificationDispatcher postNotificationName:SDLRPCServiceDidConnect infoObject:nil]; - expect(testManager.lifecycleState).toEventually(equal(SDLLifecycleStateConnected)); + [NSThread sleepForTimeInterval:SDLExpect.timeout]; + expect(testManager.lifecycleState).to(equal(SDLLifecycleStateConnected)); }); itBehavesLike(@"unable to send an RPC", ^{ return @{ @"manager": testManager }; }); @@ -318,7 +320,7 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should be in the started state", ^{ - expect(testManager.lifecycleState).toEventually(equal(SDLLifecycleStateReconnecting)); + expect(testManager.lifecycleState).to(equal(SDLLifecycleStateReconnecting)); }); }); @@ -328,7 +330,7 @@ + (void)configure:(QCKConfiguration *)configuration { [testManager.notificationDispatcher postNotificationName:SDLRPCServiceDidConnect infoObject:nil]; [testManager stop]; - expect(testManager.lifecycleState).toEventually(equal(SDLLifecycleStateStopped)); + expect(testManager.lifecycleState).to(equal(SDLLifecycleStateStopped)); }); }); }); @@ -375,7 +377,8 @@ + (void)configure:(QCKConfiguration *)configuration { testManager.hmiLevel = SDLHMILevelFull; transitionToState(SDLLifecycleStateRegistered); - expect(testManager.lifecycleState).toEventually(equal(SDLLifecycleStateReady)); + [NSThread sleepForTimeInterval:SDLExpect.timeout]; + expect(testManager.lifecycleState).to(equal(SDLLifecycleStateReady)); OCMVerify([(SDLLockScreenManager *)lockScreenManagerMock start]); OCMVerify([(SDLSystemCapabilityManager *)systemCapabilityMock start]); OCMVerify([fileManagerMock startWithCompletionHandler:[OCMArg any]]); @@ -457,11 +460,11 @@ + (void)configure:(QCKConfiguration *)configuration { OCMVerifyAllWithDelay(protocolMock, 0.5); - expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnGb)); - expect(testManager.currentVRLanguage).toEventually(equal(SDLLanguageEnGb)); - expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"EnGb")); - expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"E")); - expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(equal([SDLTTSChunk textChunksFromString:@"EnGb ttsName"])); + expect(testManager.configuration.lifecycleConfig.language).to(equal(SDLLanguageEnGb)); + expect(testManager.currentVRLanguage).to(equal(SDLLanguageEnGb)); + expect(testManager.configuration.lifecycleConfig.appName).to(equal(@"EnGb")); + expect(testManager.configuration.lifecycleConfig.shortAppName).to(equal(@"E")); + expect(testManager.configuration.lifecycleConfig.ttsName).to(equal([SDLTTSChunk textChunksFromString:@"EnGb ttsName"])); }); it(@"should not update the configuration when the app does not support the head unit language or display language", ^{ @@ -479,11 +482,11 @@ + (void)configure:(QCKConfiguration *)configuration { OCMVerifyAllWithDelay(protocolMock, 0.5); - expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnUs)); - expect(testManager.currentVRLanguage).toEventually(equal(SDLLanguageEnUs)); - expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"Test App")); - expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"Short Name")); - expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(beNil()); + expect(testManager.configuration.lifecycleConfig.language).to(equal(SDLLanguageEnUs)); + expect(testManager.currentVRLanguage).to(equal(SDLLanguageEnUs)); + expect(testManager.configuration.lifecycleConfig.appName).to(equal(@"Test App")); + expect(testManager.configuration.lifecycleConfig.shortAppName).to(equal(@"Short Name")); + expect(testManager.configuration.lifecycleConfig.ttsName).to(beNil()); }); it(@"should update when the app supports the head unit display language", ^{ @@ -513,11 +516,11 @@ + (void)configure:(QCKConfiguration *)configuration { OCMVerifyAllWithDelay(protocolMock, 0.5); - expect(testManager.configuration.lifecycleConfig.language).toEventually(equal(SDLLanguageEnGb)); - expect(testManager.currentVRLanguage).toEventually(equal(SDLLanguageEnUs)); - expect(testManager.configuration.lifecycleConfig.appName).toEventually(equal(@"EnGb")); - expect(testManager.configuration.lifecycleConfig.shortAppName).toEventually(equal(@"Gb")); - expect(testManager.configuration.lifecycleConfig.ttsName).toEventually(beNil()); + expect(testManager.configuration.lifecycleConfig.language).to(equal(SDLLanguageEnGb)); + expect(testManager.currentVRLanguage).to(equal(SDLLanguageEnUs)); + expect(testManager.configuration.lifecycleConfig.appName).to(equal(@"EnGb")); + expect(testManager.configuration.lifecycleConfig.shortAppName).to(equal(@"Gb")); + expect(testManager.configuration.lifecycleConfig.ttsName).to(beNil()); }); }); @@ -530,7 +533,8 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should enter the started state", ^{ - expect(testManager.lifecycleState).withTimeout(3.0).toEventually(equal(SDLLifecycleStateStarted)); + [NSThread sleepForTimeInterval:SDLExpect.timeout]; + expect(testManager.lifecycleState).to(equal(SDLLifecycleStateStarted)); }); }); @@ -591,9 +595,9 @@ + (void)configure:(QCKConfiguration *)configuration { [testManager.notificationDispatcher postRPCNotificationNotification:SDLDidChangeHMIStatusNotification notification:testHMIStatus]; - expect(testManager.lifecycleState).toEventually(equal(SDLLifecycleStateReady)); - expect(@(readyHandlerSuccess)).toEventually(equal(@YES)); - expect(readyHandlerError).toEventually(beNil()); + expect(testManager.lifecycleState).to(equal(SDLLifecycleStateReady)); + expect(@(readyHandlerSuccess)).to(equal(@YES)); + expect(readyHandlerError).to(beNil()); }); }); }); @@ -613,8 +617,8 @@ + (void)configure:(QCKConfiguration *)configuration { setToStateWithEnterTransition(nil, SDLLifecycleStateReady); - expect(@(readyHandlerSuccess)).toEventually(equal(@YES)); - expect(readyHandlerError).toEventually(beNil()); + expect(@(readyHandlerSuccess)).to(equal(@YES)); + expect(readyHandlerError).to(beNil()); }); }); @@ -628,10 +632,10 @@ + (void)configure:(QCKConfiguration *)configuration { setToStateWithEnterTransition(nil, SDLLifecycleStateReady); - expect(@(readyHandlerSuccess)).toEventually(equal(@YES)); - expect(readyHandlerError).toEventuallyNot(beNil()); - expect(@(readyHandlerError.code)).toEventually(equal(@(SDLManagerErrorRegistrationSuccessWithWarning))); - expect(readyHandlerError.userInfo[NSLocalizedFailureReasonErrorKey]).toEventually(match(response.info)); + expect(@(readyHandlerSuccess)).to(equal(@YES)); + expect(readyHandlerError).toNot(beNil()); + expect(@(readyHandlerError.code)).to(equal(@(SDLManagerErrorRegistrationSuccessWithWarning))); + expect(readyHandlerError.userInfo[NSLocalizedFailureReasonErrorKey]).to(match(response.info)); }); }); }); @@ -695,10 +699,11 @@ + (void)configure:(QCKConfiguration *)configuration { returnError = error; }]; - expect(returnRequest).toEventuallyNot(beNil()); - expect(returnRequest).toEventually(beAnInstanceOf([SDLShow class])); - expect(returnResponse).toEventually(beNil()); - expect(returnError).toEventuallyNot(beNil()); + [NSThread sleepForTimeInterval:SDLExpect.timeout + 3]; + expect(returnRequest).toNot(beNil()); + expect(returnRequest).to(beAnInstanceOf([SDLShow class])); + expect(returnResponse).to(beNil()); + expect(returnError).toNot(beNil()); }); it(@"can send an RPC of type Response", ^{ @@ -737,7 +742,7 @@ + (void)configure:(QCKConfiguration *)configuration { SDLRPCNotificationNotification *notification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidReceiveAppUnregisteredNotification object:testManager.notificationDispatcher rpcNotification:unreg]; [[NSNotificationCenter defaultCenter] postNotification:notification]; - expect(testManager.lifecycleState).toEventually(equal(SDLLifecycleStateStopped)); + expect(testManager.lifecycleState).to(equal(SDLLifecycleStateStopped)); }); it(@"should attempt to stop the manager when an APP_UNAUTHORIZED notification is recieved", ^{ @@ -748,7 +753,7 @@ + (void)configure:(QCKConfiguration *)configuration { SDLRPCNotificationNotification *notification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidReceiveAppUnregisteredNotification object:testManager.notificationDispatcher rpcNotification:unreg]; [[NSNotificationCenter defaultCenter] postNotification:notification]; - expect(testManager.lifecycleState).toEventually(equal(SDLLifecycleStateStopped)); + expect(testManager.lifecycleState).to(equal(SDLLifecycleStateStopped)); }); }); @@ -761,7 +766,7 @@ + (void)configure:(QCKConfiguration *)configuration { it(@"should attempt to unregister", ^{ OCMVerify([protocolMock sendRPC:[OCMArg isKindOfClass:[SDLUnregisterAppInterface class]] error:[OCMArg anyObjectRef]]); - expect(testManager.lifecycleState).toEventually(match(SDLLifecycleStateUnregistering)); + expect(testManager.lifecycleState).to(match(SDLLifecycleStateUnregistering)); }); describe(@"when receiving an unregister response", ^{ @@ -777,7 +782,7 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should stop", ^{ - expect(testManager.lifecycleState).toEventually(match(SDLLifecycleStateStopped)); + expect(testManager.lifecycleState).to(match(SDLLifecycleStateStopped)); }); }); }); @@ -801,7 +806,7 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should set the hmi level", ^{ - expect(testManager.hmiLevel).toEventually(equal(testHMILevel)); + expect(testManager.hmiLevel).to(equal(testHMILevel)); }); it(@"should call the delegate", ^{ @@ -831,7 +836,7 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should set the audio state", ^{ - expect(testManager.audioStreamingState).toEventually(equal(testAudioStreamingState)); + expect(testManager.audioStreamingState).to(equal(testAudioStreamingState)); }); it(@"should call the delegate", ^{ @@ -862,7 +867,7 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should set the audio state", ^{ - expect(testManager.videoStreamingState).toEventually(equal(testVideoStreamingState)); + expect(testManager.videoStreamingState).to(equal(testVideoStreamingState)); }); it(@"should call the delegate", ^{ @@ -896,7 +901,7 @@ + (void)configure:(QCKConfiguration *)configuration { }); it(@"should set the system context", ^{ - expect(testManager.systemContext).toEventually(equal(testSystemContext)); + expect(testManager.systemContext).to(equal(testSystemContext)); }); it(@"should call the delegate", ^{ diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m index a66dd8868a..8680ce8b1b 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m @@ -12,6 +12,7 @@ #import "SDLNotificationDispatcher.h" #import "SDLOnDriverDistraction.h" #import "SDLRPCNotificationNotification.h" +#import "SDLExpect.h" @interface SDLLockScreenManager () @@ -50,7 +51,7 @@ @interface SDLLockScreenManager () it(@"should set properties correctly", ^{ // Note: We can't check the "lockScreenPresented" flag on the Lock Screen Manager because it's a computer property checking the window - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).toEventually(beFalse()); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beFalse()); expect(testManager.lockScreenViewController).to(beNil()); }); @@ -60,7 +61,7 @@ @interface SDLLockScreenManager () }); it(@"should not have a lock screen controller", ^{ - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).toEventually(beFalse()); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beFalse()); expect(testManager.lockScreenViewController).to(beNil()); }); @@ -91,7 +92,7 @@ @interface SDLLockScreenManager () }); it(@"should set properties correctly", ^{ - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).toEventually(beFalse()); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beFalse()); expect(testManager.lockScreenViewController).to(beNil()); }); @@ -101,7 +102,7 @@ @interface SDLLockScreenManager () }); it(@"should set up the view controller correctly", ^{ - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).toEventually(beFalse()); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beFalse()); expect(testManager.lockScreenViewController).toNot(beNil()); expect(testManager.lockScreenViewController).to(beAnInstanceOf([SDLLockScreenViewController class])); }); @@ -122,7 +123,9 @@ @interface SDLLockScreenManager () it(@"should have presented the lock screen and the lockscreen should not have a vehicle icon", ^{ OCMExpect([fakeViewControllerPresenter updateLockScreenToShow:YES withCompletionHandler:[OCMArg any]]); - OCMVerifyAllWithDelay(fakeViewControllerPresenter, 0.5); + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout + 3 expectBlock:^{ + OCMVerifyAll(fakeViewControllerPresenter); + }]; expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).vehicleIcon).to(beNil()); }); @@ -139,7 +142,7 @@ @interface SDLLockScreenManager () }); it(@"should be able to be dismissed", ^{ - expect(testManager.isLockScreenDismissable).toEventually(beTrue()); + expect(testManager.isLockScreenDismissable).to(beTrue()); }); }); @@ -155,7 +158,7 @@ @interface SDLLockScreenManager () }); it(@"should not be able to be dismissed", ^{ - expect(testManager.isLockScreenDismissable).toEventually(beFalse()); + expect(testManager.isLockScreenDismissable).to(beFalse()); }); }); @@ -169,7 +172,7 @@ @interface SDLLockScreenManager () }); it(@"should not be able to be dismissed", ^{ - expect(testManager.isLockScreenDismissable).toEventually(beFalse()); + expect(testManager.isLockScreenDismissable).to(beFalse()); }); }); @@ -198,7 +201,9 @@ @interface SDLLockScreenManager () it(@"should have dismissed the lock screen", ^{ OCMExpect([fakeViewControllerPresenter updateLockScreenToShow:NO withCompletionHandler:[OCMArg any]]); - OCMVerifyAllWithDelay(fakeViewControllerPresenter, 0.5); + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout + 3 expectBlock:^{ + OCMVerifyAll(fakeViewControllerPresenter); + }]; expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beFalse()); }); @@ -226,7 +231,7 @@ @interface SDLLockScreenManager () [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidReceiveLockScreenIcon object:nil userInfo:@{ SDLNotificationUserInfoObject: testIcon }]; - expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).vehicleIcon).toEventually(equal(testIcon)); + expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).vehicleIcon).to(equal(testIcon)); }); it(@"should should not set the vehicle icon on the default lockscreen if showDeviceLogo set to false", ^{ @@ -236,7 +241,7 @@ @interface SDLLockScreenManager () [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidReceiveLockScreenIcon object:nil userInfo:@{ SDLNotificationUserInfoObject: testIcon }]; - expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).vehicleIcon).toEventually(beNil()); + expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).vehicleIcon).to(beNil()); }); it(@"should should not modify a custom lockscreen", ^{ @@ -247,7 +252,7 @@ @interface SDLLockScreenManager () [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidReceiveLockScreenIcon object:nil userInfo:@{ SDLNotificationUserInfoObject: testIcon }]; - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).lockViewController).toEventually(equal(customLockScreen)); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).lockViewController).to(equal(customLockScreen)); }); }); @@ -276,7 +281,7 @@ @interface SDLLockScreenManager () }); it(@"should set up the view controller correctly", ^{ - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).toEventually(beFalse()); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beFalse()); expect(testManager.lockScreenViewController).toNot(beNil()); expect(testManager.lockScreenViewController).to(beAnInstanceOf([SDLLockScreenViewController class])); expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).backgroundColor).to(equal(testColor)); @@ -297,7 +302,7 @@ @interface SDLLockScreenManager () }); it(@"should set properties correctly", ^{ - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).toEventually(beFalse()); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beFalse()); expect(testManager.lockScreenViewController).to(beNil()); }); @@ -307,7 +312,7 @@ @interface SDLLockScreenManager () }); it(@"should set up the view controller correctly", ^{ - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).toEventually(beFalse()); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beFalse()); expect(testManager.lockScreenViewController).toNot(beNil()); expect(testManager.lockScreenViewController).toNot(beAnInstanceOf([SDLLockScreenViewController class])); expect(testManager.lockScreenViewController).to(equal(testViewController)); @@ -344,7 +349,7 @@ @interface SDLLockScreenManager () }); it(@"should not be able to be dismissed", ^{ - expect(testManager.isLockScreenDismissable).toEventually(equal(NO)); + expect(testManager.isLockScreenDismissable).to(equal(NO)); }); }); }); @@ -375,9 +380,11 @@ @interface SDLLockScreenManager () it(@"should present the lock screen if not already presented", ^{ OCMExpect([fakeViewControllerPresenter updateLockScreenToShow:YES withCompletionHandler:[OCMArg any]]); - OCMVerifyAllWithDelay(fakeViewControllerPresenter, 0.5); + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout + 3 expectBlock:^{ + OCMVerifyAll(fakeViewControllerPresenter); + }]; - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).toEventually(beTrue()); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beTrue()); }); }); @@ -393,9 +400,11 @@ @interface SDLLockScreenManager () it(@"should present the lock screen if not already presented", ^{ OCMExpect([fakeViewControllerPresenter updateLockScreenToShow:YES withCompletionHandler:[OCMArg any]]); - OCMVerifyAllWithDelay(fakeViewControllerPresenter, 0.5); + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout + 3 expectBlock:^{ + OCMVerifyAll(fakeViewControllerPresenter); + }]; - expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).toEventually(beTrue()); + expect(((SDLFakeViewControllerPresenter *)fakeViewControllerPresenter).shouldShowLockScreen).to(beTrue()); }); }); }); @@ -425,7 +434,9 @@ @interface SDLLockScreenManager () [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidChangeLockScreenStatusNotification object:testManager.statusManager userInfo:@{SDLNotificationUserInfoObject: testOptionalStatus}]; - OCMVerifyAllWithDelay(fakeViewControllerPresenter, 0.5); + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout + 3 expectBlock:^{ + OCMVerifyAll(fakeViewControllerPresenter); + }]; }); }); @@ -442,7 +453,9 @@ @interface SDLLockScreenManager () [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidChangeLockScreenStatusNotification object:testManager.statusManager userInfo:@{SDLNotificationUserInfoObject: testOptionalStatus}]; - OCMVerifyAllWithDelay(fakeViewControllerPresenter, 0.5); + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout + 3 expectBlock:^{ + OCMVerifyAll(fakeViewControllerPresenter); + }]; }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadPresentChoicesOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadPresentChoicesOperationSpec.m index dfb910a99d..5b7cbefe6b 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadPresentChoicesOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPreloadPresentChoicesOperationSpec.m @@ -8,6 +8,7 @@ #import "SDLGlobals.h" #import "TestConnectionManager.h" +#import "SDLExpect.h" @interface SDLPreloadPresentChoicesOperation() @@ -1020,9 +1021,9 @@ @interface SDLChoiceCell() }); it(@"should finish", ^{ - expect(testOp.isExecuting).toEventually(beFalse()); - expect(testOp.isFinished).toEventually(beTrue()); - expect(testOp.isCancelled).toEventually(beTrue()); + expect(testOp.isExecuting).to(beFalse()); + expect(testOp.isFinished).to(beTrue()); + expect(testOp.isCancelled).to(beTrue()); }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m index 389e0367db..c3a9b3be64 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPresentKeyboardOperationSpec.m @@ -280,7 +280,7 @@ }); it(@"should be finished", ^{ - expect(hasCalledOperationCompletionHandler).toEventually(beTrue()); + expect(hasCalledOperationCompletionHandler).to(beTrue()); expect(testOp.isFinished).to(beTrue()); }); }); @@ -359,10 +359,10 @@ }); it(@"should not finish", ^{ - expect(hasCalledOperationCompletionHandler).toEventually(beFalse()); - expect(testOp.isExecuting).toEventually(beTrue()); - expect(testOp.isFinished).toEventually(beFalse()); - expect(testOp.isCancelled).toEventually(beFalse()); + expect(hasCalledOperationCompletionHandler).to(beFalse()); + expect(testOp.isExecuting).to(beTrue()); + expect(testOp.isFinished).to(beFalse()); + expect(testOp.isCancelled).to(beFalse()); }); }); }); @@ -464,10 +464,10 @@ }); it(@"should not attempt to send a cancel interaction but should finish", ^{ - expect(hasCalledOperationCompletionHandler).toEventually(beTrue()); - expect(testOp.isExecuting).toEventually(beFalse()); - expect(testOp.isFinished).toEventually(beTrue()); - expect(testOp.isCancelled).toEventually(beTrue()); + expect(hasCalledOperationCompletionHandler).to(beTrue()); + expect(testOp.isExecuting).to(beFalse()); + expect(testOp.isFinished).to(beTrue()); + expect(testOp.isCancelled).to(beTrue()); SDLCancelInteraction *lastRequest = testConnectionManager.receivedRequests.lastObject; expect(lastRequest).to(beNil()); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLRTPH264PacketizerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLRTPH264PacketizerSpec.m index a7d9a1eec5..e6047d97c0 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLRTPH264PacketizerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLRTPH264PacketizerSpec.m @@ -84,16 +84,24 @@ static inline UInt32 sdl_readLongInNetworkByteOrder(const UInt8 *buffer) { }); it(@"indicates version 2", ^{ - expect(@((header[FrameLengthLen] >> 6) & 3)).to(equal(@2)); + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + expect(@((header[FrameLengthLen] >> 6) & 3)).to(equal(@2)); + }); }); it(@"indicates no padding", ^{ - expect(@((header[FrameLengthLen] >> 5) & 1)).to(equal(@0)); + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + expect(@((header[FrameLengthLen] >> 5) & 1)).to(equal(@0)); + }); }); it(@"indicates no extension", ^{ - expect(@((header[FrameLengthLen] >> 4) & 1)).to(equal(@0)); + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + expect(@((header[FrameLengthLen] >> 4) & 1)).to(equal(@0)); + }); }); it(@"indicates no CSRC", ^{ - expect(@(header[FrameLengthLen] & 0xF)).to(equal(@0)); + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + expect(@(header[FrameLengthLen] & 0xF)).to(equal(@0)); + }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m index 437789ee0b..8a7fcb2317 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m @@ -213,14 +213,16 @@ - (void)sdl_displayCapabilityDidUpdate; // should set soft buttons correctly it(@"should set soft buttons correctly", ^{ - expect(testManager.softButtonObjects).toEventuallyNot(beNil()); - expect(testObject1.buttonId).toEventually(equal(1)); - expect(testObject2.buttonId).toEventually(equal(2)); - expect(testObject1.manager).toEventually(equal(testManager)); - expect(testObject2.manager).toEventually(equal(testManager)); + [NSThread sleepForTimeInterval:1.0]; + + expect(testManager.softButtonObjects).toNot(beNil()); + expect(testObject1.buttonId).to(equal(1)); + expect(testObject2.buttonId).to(equal(2)); + expect(testObject1.manager).to(equal(testManager)); + expect(testObject2.manager).to(equal(testManager)); // One replace operation - expect(testManager.transactionQueue.operationCount).toEventually(equal(1)); + expect(testManager.transactionQueue.operationCount).to(equal(1)); }); // should replace earlier operations when a replace operation is entered @@ -229,10 +231,10 @@ - (void)sdl_displayCapabilityDidUpdate; testManager.softButtonObjects = @[testObject1]; [NSThread sleepForTimeInterval:0.5]; // Necessary to not get range exceptions with toEventually? - expect(testManager.transactionQueue.operationCount).withTimeout(3.0).toEventually(equal(3)); - expect(testManager.transactionQueue.operations[0].isCancelled).withTimeout(3.0).toEventually(beTrue()); - expect(testManager.transactionQueue.operations[1].isCancelled).withTimeout(3.0).toEventually(beTrue()); - expect(testManager.transactionQueue.operations[2].isCancelled).withTimeout(3.0).toEventually(beFalse()); + expect(testManager.transactionQueue.operationCount).to(equal(3)); + expect(testManager.transactionQueue.operations[0].isCancelled).to(beTrue()); + expect(testManager.transactionQueue.operations[1].isCancelled).to(beTrue()); + expect(testManager.transactionQueue.operations[2].isCancelled).to(beFalse()); }); it(@"should retrieve soft buttons correctly", ^{ diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m index cca65997b1..51cce1f872 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m @@ -124,7 +124,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should close the streams", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateShuttingDown)); }); }); @@ -134,7 +134,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should close the stream", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateShuttingDown)); }); }); @@ -144,7 +144,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should not close the stream", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateReady)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateReady)); }); }); @@ -154,7 +154,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should not close the stream", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateReady)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateReady)); }); }); }); @@ -183,7 +183,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should close the streams", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateShuttingDown)); }); }); @@ -193,7 +193,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should close the stream", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateShuttingDown)); }); }); @@ -203,7 +203,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should not close the stream", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateReady)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateReady)); }); }); @@ -213,7 +213,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should not close the stream", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateReady)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateReady)); }); }); }); @@ -235,7 +235,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should not start the stream", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateStopped)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateStopped)); }); }); @@ -245,7 +245,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should not start the stream", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateStopped)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateStopped)); }); }); @@ -255,7 +255,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should start the streams", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateStarting)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateStarting)); }); }); @@ -265,7 +265,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should start the streams", ^{ - expect(streamingLifecycleManager.currentAudioStreamState).toEventually(equal(SDLAudioStreamManagerStateStarting)); + expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateStarting)); }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m index 36330c74db..3f805885bf 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m @@ -48,6 +48,7 @@ #import "TestConnectionManager.h" #import "TestSmartConnectionManager.h" #import "TestStreamingMediaDelegate.h" +#import "SDLExpect.h" // expose private methods to the test suite @interface SDLStreamingVideoLifecycleManager (test) @@ -299,33 +300,49 @@ - (instancetype)shortCopy; }); context(@"init extended manager", ^{ - id mockConnectionManager = OCMProtocolMock(@protocol(SDLConnectionManagerType)); - SDLConfiguration *configuration = [[SDLConfiguration alloc] init]; - SDLStreamingVideoLifecycleTestManager *streamingLifecycleManager = [[SDLStreamingVideoLifecycleTestManager alloc] initWithConnectionManager:mockConnectionManager configuration:configuration systemCapabilityManager:nil]; +// __block id mockConnectionManager; +// __block SDLStreamingVideoLifecycleTestManager *streamingLifecycleManager; + +// beforeEach(^{ +// mockConnectionManager = OCMProtocolMock(@protocol(SDLConnectionManagerType)); +// SDLConfiguration *configuration = [[SDLConfiguration alloc] init]; +// streamingLifecycleManager = [[SDLStreamingVideoLifecycleTestManager alloc] initWithConnectionManager:mockConnectionManager configuration:configuration systemCapabilityManager:nil]; +// }); context(@"test didEnterStateVideoStreamReady", ^{ it(@"expect displayLink update properly", ^{ + id mockConnectionManager = OCMProtocolMock(@protocol(SDLConnectionManagerType)); + SDLConfiguration *configuration = [[SDLConfiguration alloc] init]; + SDLStreamingVideoLifecycleTestManager *streamingLifecycleManager = [[SDLStreamingVideoLifecycleTestManager alloc] initWithConnectionManager:mockConnectionManager configuration:configuration systemCapabilityManager:nil]; + [streamingLifecycleManager useDisplayLink]; + expect(streamingLifecycleManager.displayLink).to(beNil()); [streamingLifecycleManager didEnterStateVideoStreamReady]; - expect([streamingLifecycleManager.displayLink isKindOfClass:[CADisplayLink class]]).toEventually(beTrue()); +// [NSThread sleepForTimeInterval:1.5]; + expect([streamingLifecycleManager.displayLink isKindOfClass:[CADisplayLink class]]).to(beTrue()); }); }); context(@"test didEnterStateVideoStreamSuspended", ^{ - SDLVideoStreamingCapability *videoStreamingCapabilityUpdated = OCMClassMock([SDLVideoStreamingCapability class]); - streamingLifecycleManager.videoStreamingCapabilityUpdated = videoStreamingCapabilityUpdated; it(@"expect properties to update properly", ^{ + id mockConnectionManager = OCMProtocolMock(@protocol(SDLConnectionManagerType)); + SDLConfiguration *configuration = [[SDLConfiguration alloc] init]; + SDLStreamingVideoLifecycleTestManager *streamingLifecycleManager = [[SDLStreamingVideoLifecycleTestManager alloc] initWithConnectionManager:mockConnectionManager configuration:configuration systemCapabilityManager:nil]; + + SDLVideoStreamingCapability *videoStreamingCapabilityUpdated = OCMClassMock([SDLVideoStreamingCapability class]); + streamingLifecycleManager.videoStreamingCapabilityUpdated = videoStreamingCapabilityUpdated; + streamingLifecycleManager.shouldAutoResume = YES; expect(streamingLifecycleManager.shouldAutoResume).to(equal(YES)); - expect(streamingLifecycleManager.videoStreamingCapabilityUpdated).notTo(beNil()); + expect(streamingLifecycleManager.videoStreamingCapabilityUpdated).toNot(beNil()); expect(streamingLifecycleManager.videoStreamingCapabilityUpdated).to(equal(videoStreamingCapabilityUpdated)); [streamingLifecycleManager didEnterStateVideoStreamSuspended]; expect(streamingLifecycleManager.shouldAutoResume).to(equal(NO)); - expect(streamingLifecycleManager.videoStreamingCapability).toEventually(equal(videoStreamingCapabilityUpdated)); - expect(streamingLifecycleManager.shouldAutoResume).toEventually(equal(NO)); + expect(streamingLifecycleManager.videoStreamingCapability).to(equal(videoStreamingCapabilityUpdated)); + expect(streamingLifecycleManager.shouldAutoResume).to(equal(NO)); [streamingLifecycleManager.videoStreamStateMachine transitionToState:SDLVideoStreamManagerStateStarting]; SDLProtocol *protocolMock = OCMClassMock([SDLProtocol class]); @@ -503,7 +520,7 @@ - (instancetype)shortCopy; }); it(@"should save the connected vehicle make but not the screen size", ^{ - expect(@(CGSizeEqualToSize(streamingLifecycleManager.videoScaleManager.displayViewportResolution, CGSizeZero))).toEventually(equal(@YES)); + expect(@(CGSizeEqualToSize(streamingLifecycleManager.videoScaleManager.displayViewportResolution, CGSizeZero))).to(equal(@YES)); }); }); @@ -533,7 +550,7 @@ - (instancetype)shortCopy; }); it(@"should save the connected vehicle make and the screen size", ^{ - expect(@(CGSizeEqualToSize(streamingLifecycleManager.videoScaleManager.displayViewportResolution, CGSizeMake(600, 100)))).toEventually(equal(@YES)); + expect(@(CGSizeEqualToSize(streamingLifecycleManager.videoScaleManager.displayViewportResolution, CGSizeMake(600, 100)))).to(equal(@YES)); }); }); }); @@ -565,7 +582,7 @@ - (instancetype)shortCopy; }); it(@"should close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateShuttingDown)); }); }); @@ -575,7 +592,7 @@ - (instancetype)shortCopy; }); it(@"should close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateShuttingDown)); }); }); @@ -585,7 +602,7 @@ - (instancetype)shortCopy; }); it(@"should not close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateReady)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateReady)); }); }); @@ -595,7 +612,7 @@ - (instancetype)shortCopy; }); it(@"should not close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateReady)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateReady)); }); }); @@ -605,7 +622,7 @@ - (instancetype)shortCopy; }); it(@"should close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateShuttingDown)); }); }); }); @@ -634,7 +651,7 @@ - (instancetype)shortCopy; }); it(@"should close the streams", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateShuttingDown)); }); }); @@ -644,7 +661,7 @@ - (instancetype)shortCopy; }); it(@"should close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateShuttingDown)); }); }); @@ -654,7 +671,7 @@ - (instancetype)shortCopy; }); it(@"should not close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateReady)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateReady)); }); }); @@ -664,7 +681,7 @@ - (instancetype)shortCopy; }); it(@"should not close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateReady)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateReady)); }); }); @@ -674,7 +691,7 @@ - (instancetype)shortCopy; }); it(@"should close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateShuttingDown)); }); }); @@ -685,7 +702,7 @@ - (instancetype)shortCopy; }); it(@"should close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateShuttingDown)); }); }); @@ -696,7 +713,7 @@ - (instancetype)shortCopy; }); it(@"should close the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateShuttingDown)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateShuttingDown)); }); }); }); @@ -720,7 +737,7 @@ - (instancetype)shortCopy; }); it(@"should not start the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateStopped)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateStopped)); }); }); @@ -730,7 +747,7 @@ - (instancetype)shortCopy; }); it(@"should not start the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateStopped)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateStopped)); }); }); @@ -740,7 +757,7 @@ - (instancetype)shortCopy; }); it(@"should start the streams", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateStarting)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateStarting)); }); }); @@ -750,7 +767,7 @@ - (instancetype)shortCopy; }); it(@"should start the streams", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateStarting)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateStarting)); }); }); @@ -760,7 +777,7 @@ - (instancetype)shortCopy; }); it(@"should not start the stream", ^{ - expect(streamingLifecycleManager.currentVideoStreamState).toEventually(equal(SDLVideoStreamManagerStateStopped)); + expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamManagerStateStopped)); }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m index 4b4b0ecf9e..89b41d36d1 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m @@ -14,6 +14,7 @@ #import "SDLVersion.h" #import "TestConnectionManager.h" #import +#import "SDLExpect.h" @interface UploadFileOperationSpecHelpers : NSObject @@ -212,8 +213,10 @@ + (NSUInteger)testMaxBulkDataSizeForFile:(SDLFile *)file mtuSize:(NSUInteger)mtu [testConnectionManager respondToRequestWithResponse:successResponse requestNumber:i error:nil]; } - expect(testOperation.finished).toEventually(beTrue()); - expect(testOperation.executing).toEventually(beFalse()); + [SDLExpect SDLExpectWithTimeout:3 expectBlock:^{ + expect(testOperation.finished).to(beTrue()); + expect(testOperation.executing).to(beFalse()); + }]; }); it(@"should split the data from a large image in memory correctly", ^{ @@ -245,8 +248,10 @@ + (NSUInteger)testMaxBulkDataSizeForFile:(SDLFile *)file mtuSize:(NSUInteger)mtu [testConnectionManager respondToRequestWithResponse:successResponse requestNumber:i error:nil]; } - expect(testOperation.finished).toEventually(beTrue()); - expect(testOperation.executing).toEventually(beFalse()); + [SDLExpect SDLExpectWithTimeout:3 expectBlock:^{ + expect(testOperation.finished).to(beTrue()); + expect(testOperation.executing).to(beFalse()); + }]; }); it(@"should split the data from a small text file correctly", ^{ @@ -279,8 +284,10 @@ + (NSUInteger)testMaxBulkDataSizeForFile:(SDLFile *)file mtuSize:(NSUInteger)mtu [testConnectionManager respondToRequestWithResponse:successResponse requestNumber:i error:nil]; } - expect(testOperation.finished).toEventually(beTrue()); - expect(testOperation.executing).toEventually(beFalse()); + [SDLExpect SDLExpectWithTimeout:3 expectBlock:^{ + expect(testOperation.finished).to(beTrue()); + expect(testOperation.executing).to(beFalse()); + }]; }); it(@"should split the data from a large image file correctly", ^{ @@ -314,8 +321,10 @@ + (NSUInteger)testMaxBulkDataSizeForFile:(SDLFile *)file mtuSize:(NSUInteger)mtu [testConnectionManager respondToRequestWithResponse:successResponse requestNumber:i error:nil]; } - expect(testOperation.finished).toEventually(beTrue()); - expect(testOperation.executing).toEventually(beFalse()); + [SDLExpect SDLExpectWithTimeout:3 expectBlock:^{ + expect(testOperation.finished).to(beTrue()); + expect(testOperation.executing).to(beFalse()); + }]; }); }); }); @@ -356,12 +365,13 @@ + (NSUInteger)testMaxBulkDataSizeForFile:(SDLFile *)file mtuSize:(NSUInteger)mtu [testConnectionManager respondToRequestWithResponse:successResponse requestNumber:i error:nil]; } - expect(successResult).toEventually(beTrue()); - expect(bytesAvailableResult).toEventually(equal(spaceLeft)); - expect(errorResult).toEventually(beNil()); + [NSThread sleepForTimeInterval:1.0]; + expect(successResult).to(beTrue()); + expect(bytesAvailableResult).to(equal(spaceLeft)); + expect(errorResult).to(beNil()); - expect(testOperation.finished).toEventually(beTrue()); - expect(testOperation.executing).toEventually(beFalse()); + expect(testOperation.finished).to(beTrue()); + expect(testOperation.executing).to(beFalse()); }); }); @@ -400,9 +410,11 @@ + (NSUInteger)testMaxBulkDataSizeForFile:(SDLFile *)file mtuSize:(NSUInteger)mtu }); it(@"should have called the completion handler with error", ^{ - expect(errorResult.localizedDescription).toEventually(match(responseErrorDescription)); - expect(errorResult.localizedFailureReason).toEventually(match(responseErrorReason)); - expect(successResult).toEventually(beFalse()); + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout expectBlock:^{ + expect(errorResult.localizedDescription).to(match(responseErrorDescription)); + expect(errorResult.localizedFailureReason).to(match(responseErrorReason)); + expect(successResult).to(beFalse()); + }]; }); }); @@ -426,9 +438,10 @@ + (NSUInteger)testMaxBulkDataSizeForFile:(SDLFile *)file mtuSize:(NSUInteger)mtu [testConnectionManager respondToRequestWithResponse:response requestNumber:i error:error]; } - expect(errorResult.localizedDescription).toEventually(match(responseErrorDescription)); - expect(errorResult.localizedFailureReason).toEventually(match(responseErrorReason)); - expect(successResult).toEventually(beFalse()); + sleep(SDLExpect.timeout + 3); + expect(errorResult.localizedDescription).to(match(responseErrorDescription)); + expect(errorResult.localizedFailureReason).to(match(responseErrorReason)); + expect(successResult).to(beFalse()); }); }); @@ -444,10 +457,10 @@ + (NSUInteger)testMaxBulkDataSizeForFile:(SDLFile *)file mtuSize:(NSUInteger)mtu [testConnectionManager respondToRequestWithResponse:response requestNumber:i error:[NSError sdl_lifecycle_unknownRemoteErrorWithDescription:responseErrorDescription andReason:responseErrorReason]]; } - - expect(errorResult.localizedDescription).toEventually(match(responseErrorDescription)); - expect(errorResult.localizedFailureReason).toEventually(match(responseErrorReason)); - expect(successResult).toEventually(beFalse()); + [NSThread sleepForTimeInterval:1.0]; + expect(errorResult.localizedDescription).to(match(responseErrorDescription)); + expect(errorResult.localizedFailureReason).to(match(responseErrorReason)); + expect(successResult).to(beFalse()); }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m index 612d89aa25..3908c32048 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m @@ -13,6 +13,7 @@ #import "SDLVoiceCommandManager.h" #import "SDLVoiceCommandUpdateOperation.h" #import "TestConnectionManager.h" +#import "SDLExpect.h" @interface SDLVoiceCommandUpdateOperation () @@ -166,7 +167,10 @@ + (BOOL)sdl_arePendingVoiceCommandsUnique:(NSArray *)voiceCom }); it(@"should update the second operation", ^{ - expect(((SDLVoiceCommandUpdateOperation *)testManager.transactionQueue.operations.firstObject).oldVoiceCommands.firstObject).to(equal(testVoiceCommand2)); + [NSThread sleepForTimeInterval:3.0]; + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout expectBlock:^{ + expect(((SDLVoiceCommandUpdateOperation *)testManager.transactionQueue.operations.firstObject).oldVoiceCommands.firstObject).to(equal(testVoiceCommand2)); + }]; }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandUpdateOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandUpdateOperationSpec.m index 2eb5f9eb37..0e8a011664 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandUpdateOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandUpdateOperationSpec.m @@ -119,7 +119,7 @@ @interface SDLVoiceCommandUpdateOperation() }); it(@"should return immediately with an error", ^{ - expect(callbackError).toEventuallyNot(beNil()); + expect(callbackError).toNot(beNil()); }); }); diff --git a/SmartDeviceLinkTests/Notifications/SDLNotificationDispatcherSpec.m b/SmartDeviceLinkTests/Notifications/SDLNotificationDispatcherSpec.m index 435cea5694..30114b096f 100644 --- a/SmartDeviceLinkTests/Notifications/SDLNotificationDispatcherSpec.m +++ b/SmartDeviceLinkTests/Notifications/SDLNotificationDispatcherSpec.m @@ -36,8 +36,8 @@ }); it(@"should post", ^{ - expect(returnNotification.userInfo[SDLNotificationUserInfoObject]).toEventually(match(testUserInfo)); - expect(returnNotification.object).toEventually(equal(testDispatcher)); + expect(returnNotification.userInfo[SDLNotificationUserInfoObject]).to(match(testUserInfo)); + expect(returnNotification.object).to(equal(testDispatcher)); }); }); @@ -59,9 +59,9 @@ }); it(@"should successfully post a response", ^{ - expect(testNotification.name).toEventually(equal(testNotificationName)); - expect(testNotification.response).toEventually(equal(testResponse)); - expect(testNotification.object).toEventually(equal(testDispatcher)); + expect(testNotification.name).to(equal(testNotificationName)); + expect(testNotification.response).to(equal(testResponse)); + expect(testNotification.object).to(equal(testDispatcher)); }); }); @@ -83,9 +83,9 @@ }); it(@"should successfully post a request", ^{ - expect(testNotification.name).toEventually(equal(testNotificationName)); - expect(testNotification.request).toEventually(equal(testRequest)); - expect(testNotification.object).toEventually(equal(testDispatcher)); + expect(testNotification.name).to(equal(testNotificationName)); + expect(testNotification.request).to(equal(testRequest)); + expect(testNotification.object).to(equal(testDispatcher)); }); }); @@ -107,9 +107,9 @@ }); it(@"should successfully post a notification", ^{ - expect(testNotification.name).toEventually(equal(testNotificationName)); - expect(testNotification.notification).toEventually(equal(testNotificationRequest)); - expect(testNotification.object).toEventually(equal(testDispatcher)); + expect(testNotification.name).to(equal(testNotificationName)); + expect(testNotification.notification).to(equal(testNotificationRequest)); + expect(testNotification.object).to(equal(testDispatcher)); }); }); }); diff --git a/SmartDeviceLinkTests/Notifications/SDLResponseDispatcherSpec.m b/SmartDeviceLinkTests/Notifications/SDLResponseDispatcherSpec.m index 9dcff09b7e..e247db38ca 100644 --- a/SmartDeviceLinkTests/Notifications/SDLResponseDispatcherSpec.m +++ b/SmartDeviceLinkTests/Notifications/SDLResponseDispatcherSpec.m @@ -30,7 +30,7 @@ #import "SDLTextAlignment.h" #import "SDLUnsubscribeButton.h" #import "SDLUnsubscribeButtonResponse.h" - +#import "SDLExpect.h" QuickSpecBegin(SDLResponseDispatcherSpec) @@ -112,7 +112,8 @@ }); it(@"should run the handler", ^{ - expect(@(handlerCalled)).toEventually(beTrue()); + sleep(SDLExpect.timeout); + expect(@(handlerCalled)).to(beTrue()); expect(testDispatcher.rpcRequestDictionary).to(haveCount(@0)); expect(testDispatcher.rpcResponseHandlerMap).to(haveCount(@0)); }); diff --git a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m index 0dee191ef8..1de91477f5 100644 --- a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m +++ b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m @@ -67,7 +67,7 @@ [testProtocol startServiceWithType:SDLServiceTypeBulkData payload:nil]; - expect(verified).toEventually(beTrue()); + expect(verified).to(beTrue()); }); it(@"Should reuse stored header of RPC service when starting other service", ^{ @@ -103,7 +103,7 @@ [testProtocol storeHeader:header forServiceType:SDLServiceTypeRPC]; [testProtocol startServiceWithType:serviceTypeToStart payload:nil]; - expect(verified).toEventually(beTrue()); + expect(verified).to(beTrue()); }); }); @@ -144,7 +144,7 @@ [testProtocol endServiceWithType:SDLServiceTypeRPC]; - expect(verified).toEventually(beTrue()); + expect(verified).to(beTrue()); }); }); @@ -172,7 +172,7 @@ [testProtocol endServiceWithType:SDLServiceTypeRPC]; - expect(verified).toEventually(beTrue()); + expect(verified).to(beTrue()); }); }); }); @@ -208,7 +208,7 @@ [testProtocol registerSecondaryTransport]; - expect(verified).toEventually(beTrue()); + expect(verified).to(beTrue()); }); }); @@ -258,7 +258,7 @@ NSError *error = nil; BOOL sent = [testProtocol sendRPC:mockRequest error:&error]; - expect(verified).toEventually(beTrue()); + expect(verified).to(beTrue()); expect(sent).to(beTrue()); expect(error).to(beNil()); }); @@ -293,7 +293,7 @@ NSError *error = nil; BOOL sent = [testProtocol sendRPC:mockRequest error:&error]; - expect(numTimesCalled).toEventually(equal(1)); + expect(numTimesCalled).to(equal(1)); expect(sent).to(beTrue()); expect(error).to(beNil()); }); @@ -317,7 +317,7 @@ [SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion = [SDLVersion versionWithMajor:2 minor:0 patch:0]; BOOL sent = [testProtocol sendRPC:deleteRequest error:&error]; - expect(numTimesCalled).toEventually(equal(3)); + expect(numTimesCalled).to(equal(3)); expect(sent).to(beTrue()); expect(error).to(beNil()); }); @@ -344,7 +344,7 @@ [SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion = [SDLVersion versionWithMajor:5 minor:0 patch:0]; BOOL sent = [testProtocol sendRPC:deleteRequest error:&error]; - expect(numTimesCalled).toEventually(equal(0)); + expect(numTimesCalled).to(equal(0)); expect(sent).to(beFalse()); expect(error).toNot(beNil()); }); @@ -363,10 +363,13 @@ SDLEncryptionLifecycleManager *encryptionMock = OCMClassMock([SDLEncryptionLifecycleManager class]); OCMStub(encryptionMock.isEncryptionReady).andReturn(YES); + [NSThread sleepForTimeInterval:1.0]; + id securityManager = OCMProtocolMock(@protocol(SDLSecurityType)); char dummyBytes[dataSize]; NSData *returnData = [NSData dataWithBytes:dummyBytes length:dataSize]; OCMStub([securityManager encryptData:[OCMArg any] withError:[OCMArg setTo:nil]]).andReturn(returnData); + [NSThread sleepForTimeInterval:0.5]; testProtocol = [[SDLProtocol alloc] initWithTransport:transportMock encryptionManager:encryptionMock]; testProtocol.securityManager = securityManager; @@ -384,7 +387,7 @@ [SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion = [SDLVersion versionWithMajor:5 minor:0 patch:0]; BOOL sent = [testProtocol sendRPC:deleteRequest error:&error]; - expect(numTimesCalled).toEventually(equal(3)); + expect(numTimesCalled).to(equal(3)); expect(sent).to(beTrue()); expect(error).to(beNil()); }); diff --git a/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m index c1e9f6f1e9..5ddc0cacfc 100644 --- a/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m +++ b/SmartDeviceLinkTests/ProtocolSpecs/SDLProtocolReceivedMessageRouterSpec.m @@ -14,6 +14,7 @@ #import "SDLRPCParameterNames.h" #import "SDLV2ProtocolHeader.h" #import "SDLV2ProtocolMessage.h" +#import "SDLExpect.h" QuickSpecBegin(SDLProtocolReceivedMessageRouterSpec) @@ -156,7 +157,7 @@ [router handleReceivedMessage:testMessage protocol:mockProtocol]; - expect(verified).toEventually(beTrue()); + expect(verified).to(beTrue()); }); }); @@ -210,10 +211,13 @@ testMessage.header.frameData = 0; testMessage.payload = [payloadData subdataWithRange:NSMakeRange(offset, payloadData.length - offset)]; + XCTestExpectation *myExpectation = [self expectationWithDescription:@"Expectation for the following async block"]; __block BOOL verified = NO; [OCMStub([delegateMock protocol:mockProtocol didReceiveMessage:[OCMArg any]]) andDo:^(NSInvocation *invocation) { + [NSThread sleepForTimeInterval:0.5]; verified = YES; - + [myExpectation fulfill]; + // Without the __unsafe_unretained, a double release will occur. More information: https://github.com/erikdoe/ocmock/issues/123 __unsafe_unretained SDLProtocolMessage *message; [invocation getArgument:&message atIndex:3]; @@ -228,8 +232,9 @@ }]; [router handleReceivedMessage:testMessage protocol:mockProtocol]; - - expect(verified).toEventually(beTrue()); + + [self waitForExpectationsWithTimeout:SDLExpect.timeout handler:nil]; + XCTAssertTrue(verified); }); }); }); diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m index bcde097a73..afd456dd28 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m @@ -405,7 +405,7 @@ @interface SDLFocusableItemLocator () it(@"should have one view", ^{ int expectedCount = 1; - expect(sentHapticRequest.hapticRectData.count).toEventually(equal(expectedCount)); + expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); if(sentHapticRequest.hapticRectData.count == expectedCount) { NSArray *hapticRectData = sentHapticRequest.hapticRectData; @@ -426,7 +426,7 @@ @interface SDLFocusableItemLocator () it(@"should have two views", ^{ int expectedCount = 2; - expect(sentHapticRequest.hapticRectData.count).toEventually(equal(expectedCount)); + expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); if(sentHapticRequest.hapticRectData.count == expectedCount) { NSArray *hapticRectData = sentHapticRequest.hapticRectData; @@ -450,7 +450,7 @@ @interface SDLFocusableItemLocator () it(@"should have two views", ^{ int expectedCount = 2; - expect(sentHapticRequest.hapticRectData.count).toEventually(equal(expectedCount)); + expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount)); }); }); }); diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m index 9b424cc279..3f9969a4ef 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m @@ -26,6 +26,7 @@ #import "SDLTCPTransport.h" #import "SDLTimer.h" #import "SDLV2ProtocolMessage.h" +#import "SDLExpect.h" /* copied from SDLSecondaryTransportManager.m */ typedef NSNumber SDLServiceTypeBox; @@ -257,13 +258,16 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve OCMExpect([testStreamingProtocolDelegate didUpdateFromOldVideoProtocol:nil toNewVideoProtocol:nil fromOldAudioProtocol:nil toNewAudioProtocol:testPrimaryProtocol]); [testPrimaryProtocol onDataReceived:testStartServiceACKMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); - expect((NSInteger)manager.secondaryTransportType).toEventually(equal(SDLTransportSelectionTCP)); + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); + + expect((NSInteger)manager.secondaryTransportType).to(equal(SDLTransportSelectionTCP)); NSArray *expectedTransportsForAudioService = @[@(SDLTransportClassSecondary), @(SDLTransportClassPrimary)]; - expect(manager.transportsForAudioService).toEventually(equal(expectedTransportsForAudioService)); + expect(manager.transportsForAudioService).to(equal(expectedTransportsForAudioService)); NSArray *expectedTransportsForVideoService = @[@(SDLTransportClassSecondary)]; - expect(manager.transportsForVideoService).toEventually(equal(expectedTransportsForVideoService)); + expect(manager.transportsForVideoService).to(equal(expectedTransportsForVideoService)); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); @@ -284,10 +288,12 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testPrimaryProtocol onDataReceived:testStartServiceACKMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); - expect((NSInteger)manager.secondaryTransportType).toEventually(equal(SDLTransportSelectionTCP)); - expect(manager.transportsForAudioService).toEventually(equal(@[@(SDLTransportClassPrimary)])); - expect(manager.transportsForVideoService).toEventually(equal(@[@(SDLTransportClassPrimary)])); + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); + expect((NSInteger)manager.secondaryTransportType).to(equal(SDLTransportSelectionTCP)); + expect(manager.transportsForAudioService).to(equal(@[@(SDLTransportClassPrimary)])); + expect(manager.transportsForVideoService).to(equal(@[@(SDLTransportClassPrimary)])); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); @@ -309,10 +315,12 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testPrimaryProtocol onDataReceived:testStartServiceACKMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); - expect((NSInteger)manager.secondaryTransportType).toEventually(equal(SDLTransportSelectionDisabled)); - expect(manager.transportsForAudioService).toEventually(equal(@[@(SDLTransportClassPrimary)])); - expect(manager.transportsForVideoService).toEventually(equal(@[@(SDLTransportClassPrimary)])); + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); + expect((NSInteger)manager.secondaryTransportType).to(equal(SDLTransportSelectionDisabled)); + expect(manager.transportsForAudioService).to(equal(@[@(SDLTransportClassPrimary)])); + expect(manager.transportsForVideoService).to(equal(@[@(SDLTransportClassPrimary)])); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); @@ -329,11 +337,12 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve OCMExpect([testStreamingProtocolDelegate didUpdateFromOldVideoProtocol:nil toNewVideoProtocol:testPrimaryProtocol fromOldAudioProtocol:nil toNewAudioProtocol:testPrimaryProtocol]); [testPrimaryProtocol onDataReceived:testStartServiceACKMessage.data]; + [NSThread sleepForTimeInterval:3.0]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); - expect((NSInteger)manager.secondaryTransportType).toEventually(equal(SDLTransportSelectionDisabled)); - expect(manager.transportsForAudioService).toEventually(equal(@[@(SDLTransportClassPrimary)])); - expect(manager.transportsForVideoService).toEventually(equal(@[@(SDLTransportClassPrimary)])); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); + expect((NSInteger)manager.secondaryTransportType).to(equal(SDLTransportSelectionDisabled)); + expect(manager.transportsForAudioService).to(equal(@[@(SDLTransportClassPrimary)])); + expect(manager.transportsForVideoService).to(equal(@[@(SDLTransportClassPrimary)])); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); @@ -364,12 +373,12 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateStarted)); - expect((NSInteger)manager.secondaryTransportType).toEventually(equal(SDLTransportSelectionDisabled)); - expect(manager.transportsForAudioService).toEventually(equal(@[])); - expect(manager.transportsForVideoService).toEventually(equal(@[])); - expect(manager.ipAddress).toEventually(equal(testTcpIpAddress)); - expect(manager.tcpPort).toEventually(equal(testTcpPort)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStarted)); + expect((NSInteger)manager.secondaryTransportType).to(equal(SDLTransportSelectionDisabled)); + expect(manager.transportsForAudioService).to(equal(@[])); + expect(manager.transportsForVideoService).to(equal(@[])); + expect(manager.ipAddress).to(equal(testTcpIpAddress)); + expect(manager.tcpPort).to(equal(testTcpPort)); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); @@ -424,19 +433,21 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; [testPrimaryProtocol onDataReceived:testStartServiceACKMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConnecting)); - expect((NSInteger)manager.secondaryTransportType).toEventually(equal(SDLTransportSelectionTCP)); + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConnecting)); + expect((NSInteger)manager.secondaryTransportType).to(equal(SDLTransportSelectionTCP)); NSArray *expectedTransportsForAudioService = @[@(SDLTransportClassSecondary)]; - expect(manager.transportsForAudioService).toEventually(equal(expectedTransportsForAudioService)); + expect(manager.transportsForAudioService).to(equal(expectedTransportsForAudioService)); NSArray *expectedTransportsForVideoService = @[@(SDLTransportClassSecondary)]; - expect(manager.transportsForVideoService).toEventually(equal(expectedTransportsForVideoService)); - expect(manager.ipAddress).toEventually(equal(testTcpIpAddress)); - expect(manager.tcpPort).toEventually(equal(testTcpPort)); + expect(manager.transportsForVideoService).to(equal(expectedTransportsForVideoService)); + expect(manager.ipAddress).to(equal(testTcpIpAddress)); + expect(manager.tcpPort).to(equal(testTcpPort)); SDLTCPTransport *secondaryTransport = (SDLTCPTransport *)manager.secondaryTransport; - expect(secondaryTransport.hostName).toEventually(equal(testTcpIpAddress)); + expect(secondaryTransport.hostName).to(equal(testTcpIpAddress)); NSString *portNumberString = [NSString stringWithFormat:@"%d", testTcpPort]; - expect(secondaryTransport.portNumber).toEventually(equal(portNumberString)); + expect(secondaryTransport.portNumber).to(equal(portNumberString)); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); @@ -461,15 +472,17 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; [testPrimaryProtocol onDataReceived:testStartServiceACKMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); - expect((NSInteger)manager.secondaryTransportType).toEventually(equal(SDLTransportSelectionTCP)); + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); + expect((NSInteger)manager.secondaryTransportType).to(equal(SDLTransportSelectionTCP)); NSArray *expectedTransportsForAudioService = @[@(SDLTransportClassSecondary)]; - expect(manager.transportsForAudioService).toEventually(equal(expectedTransportsForAudioService)); + expect(manager.transportsForAudioService).to(equal(expectedTransportsForAudioService)); NSArray *expectedTransportsForVideoService = @[@(SDLTransportClassSecondary)]; - expect(manager.transportsForVideoService).toEventually(equal(expectedTransportsForVideoService)); - expect(manager.ipAddress).toEventually(equal(testTcpIpAddress)); - expect(manager.tcpPort).toEventually(equal(testTcpPort)); - expect(manager.secondaryTransport).toEventually(beNil()); + expect(manager.transportsForVideoService).to(equal(expectedTransportsForVideoService)); + expect(manager.ipAddress).to(equal(testTcpIpAddress)); + expect(manager.tcpPort).to(equal(testTcpPort)); + expect(manager.secondaryTransport).to(beNil()); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); @@ -478,13 +491,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve describe(@"when stopped", ^{ it(@"should transition to the Stopped state", ^{ - waitUntilTimeout(1, ^(void (^done)(void)){ - dispatch_sync(testStateMachineQueue, ^{ - [manager stopWithCompletionHandler:^{ - expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); - done(); - }]; - }); + dispatch_sync(testStateMachineQueue, ^{ + [manager stopWithCompletionHandler:^{ + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); + }]; }); }); }); @@ -579,9 +589,9 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve context(@"before the app context is HMI FULL", ^{ it(@"should stay in Configured state", ^{ - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); - expect(manager.currentHMILevel).toEventually(beNil()); - expect(manager.secondaryProtocol.securityManager).toEventually(beNil()); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); + expect(manager.currentHMILevel).to(beNil()); + expect(manager.secondaryProtocol.securityManager).to(beNil()); }); }); @@ -591,9 +601,9 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should transition to Connecting", ^{ - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConnecting)); - expect(manager.currentHMILevel).toEventually(equal(SDLHMILevelFull)); - expect(manager.secondaryProtocol.securityManager).toEventually(equal(testPrimaryProtocol.securityManager)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConnecting)); + expect(manager.currentHMILevel).to(equal(SDLHMILevelFull)); + expect(manager.secondaryProtocol.securityManager).to(equal(testPrimaryProtocol.securityManager)); }); }); }); @@ -612,13 +622,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should transition to Stopped state", ^{ - waitUntilTimeout(1, ^(void (^done)(void)){ - dispatch_sync(testStateMachineQueue, ^{ - [manager stopWithCompletionHandler:^{ - expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); - done(); - }]; - }); + dispatch_sync(testStateMachineQueue, ^{ + [manager stopWithCompletionHandler:^{ + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); + }]; }); }); }); @@ -681,7 +688,9 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onDataReceived:testRegisterSecondaryTransportAckMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateRegistered)); + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateRegistered)); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); }); @@ -704,7 +713,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should transition to Reconnecting state", ^{ [testSecondaryProtocolMock onDataReceived:testRegisterSecondaryTransportNakMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateReconnecting)); }); }); @@ -729,7 +741,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [NSThread sleepForTimeInterval:RegisterTransportTime]; // This still needs to be here to ensure that the Verify happens correctly OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateReconnecting)); }); it(@"if not in the Connecting state it should not try to reconnect", ^{ @@ -739,7 +754,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onTransportConnected]; - expect(manager.stateMachine.currentState).withTimeout(3.0).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + expect(manager.stateMachine.currentState).withTimeout(3.0).to(equal(SDLSecondaryTransportStateReconnecting)); }); }); }); @@ -750,7 +765,9 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onTransportDisconnected]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateReconnecting)); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); }); @@ -784,7 +801,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should ignore the frame and stay in Connecting state", ^{ [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConnecting)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConnecting)); }); }); @@ -800,7 +817,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should transition to Configured state, then transition to Connecting state again", ^{ [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConnecting)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConnecting)); }); }); @@ -815,7 +832,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should transition to Configured state", ^{ [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); + + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); }); }); @@ -823,13 +843,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve describe(@"when stopped", ^{ it(@"should transition to Stopped state", ^{ - waitUntilTimeout(1, ^(void (^done)(void)){ - dispatch_sync(testStateMachineQueue, ^{ - [manager stopWithCompletionHandler:^{ - expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); - done(); - }]; - }); + dispatch_sync(testStateMachineQueue, ^{ + [manager stopWithCompletionHandler:^{ + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); + }]; }); }); }); @@ -894,7 +911,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should ignore the frame and stay in Registered state", ^{ [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateRegistered)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateRegistered)); }); }); @@ -911,7 +928,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve OCMExpect([testStreamingProtocolDelegate didUpdateFromOldVideoProtocol:secondaryProtocol toNewVideoProtocol:nil fromOldAudioProtocol:secondaryProtocol toNewAudioProtocol:nil]); [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConnecting)); + + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConnecting)); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); }); @@ -929,7 +949,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve OCMExpect([testStreamingProtocolDelegate didUpdateFromOldVideoProtocol:secondaryProtocol toNewVideoProtocol:nil fromOldAudioProtocol:secondaryProtocol toNewAudioProtocol:nil]); [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); + + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); }); @@ -949,7 +972,9 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onTransportDisconnected]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + [NSThread sleepForTimeInterval:3.0]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateReconnecting)); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); }); }); @@ -966,13 +991,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should transition to Stopped state", ^{ OCMExpect([testStreamingProtocolDelegate didUpdateFromOldVideoProtocol:secondaryProtocol toNewVideoProtocol:nil fromOldAudioProtocol:secondaryProtocol toNewAudioProtocol:nil]); - waitUntilTimeout(1, ^(void (^done)(void)){ - dispatch_sync(testStateMachineQueue, ^{ - [manager stopWithCompletionHandler:^{ - expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); - done(); - }]; - }); + dispatch_sync(testStateMachineQueue, ^{ + [manager stopWithCompletionHandler:^{ + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); + }]; }); }); }); @@ -1002,7 +1024,9 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [manager.stateMachine setToState:SDLSecondaryTransportStateReconnecting fromOldState:nil callEnterTransition:YES]; }); - expect(manager.stateMachine.currentState).withTimeout(RetryConnectionDelay + 3.0).toEventually(equal(SDLSecondaryTransportStateConfigured)); + [NSThread sleepForTimeInterval:(RetryConnectionDelay + 3.0)]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); }); }); @@ -1035,7 +1059,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should ignore the frame and stay in Reconnecting state", ^{ [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateReconnecting)); }); }); @@ -1051,7 +1075,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should transition to Configured state before timeout, then transition to Connecting state again", ^{ [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConnecting)); + + [NSThread sleepForTimeInterval:(RetryConnectionDelay + 3.0)]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConnecting)); }); }); @@ -1066,20 +1093,20 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should transition to Configured state before timeout", ^{ [testPrimaryProtocol onDataReceived:testTransportEventUpdateMessage.data]; - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); + + [NSThread sleepForTimeInterval:(RetryConnectionDelay + 3.0)]; + + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); }); }); }); describe(@"when stopped", ^{ it(@"should transition to Stopped state", ^{ - waitUntilTimeout(1, ^(void (^done)(void)){ - dispatch_sync(testStateMachineQueue, ^{ - [manager stopWithCompletionHandler:^{ - expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); - done(); - }]; - }); + dispatch_sync(testStateMachineQueue, ^{ + [manager stopWithCompletionHandler:^{ + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); + }]; }); }); }); @@ -1118,7 +1145,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillResignActiveNotification object:nil]; OCMVerifyAllWithDelay(mockBackgroundTaskManager, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateRegistered)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateRegistered)); }); }); @@ -1134,7 +1161,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillResignActiveNotification object:nil]; OCMVerifyAllWithDelay(mockBackgroundTaskManager, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); }); }); @@ -1152,7 +1179,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidBecomeActiveNotification object:nil]; OCMVerifyAllWithDelay(mockBackgroundTaskManager, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateRegistered)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateRegistered)); }); }); @@ -1173,7 +1200,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidBecomeActiveNotification object:nil]; OCMVerifyAllWithDelay(mockBackgroundTaskManager, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConnecting)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConnecting)); }); }); @@ -1188,7 +1215,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidBecomeActiveNotification object:nil]; OCMVerifyAllWithDelay(mockBackgroundTaskManager, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConnecting)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConnecting)); }); }); }); @@ -1200,12 +1227,17 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); 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]; - - BOOL waitForCleanupToFinish = manager.sdl_backgroundTaskEndedHandler(); - - expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); - expect(waitForCleanupToFinish).to(beTrue()); + __block BOOL waitForCleanupToFinish; + dispatch_sync(testStateMachineQueue, ^{ + [manager.stateMachine setToState:SDLSecondaryTransportStateRegistered fromOldState:nil callEnterTransition:NO]; + waitForCleanupToFinish = manager.sdl_backgroundTaskEndedHandler(); + }); + + [NSThread sleepForTimeInterval:3]; + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout expectBlock:^{ + 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 and immediately end the background task", ^{ @@ -1263,7 +1295,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onTransportDisconnected]; OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateReconnecting)); }); it(@"should transition to Reconnecting state if in state registered", ^{ @@ -1276,7 +1308,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onTransportDisconnected]; OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateReconnecting)); }); it(@"should stay in the same state if not in the connecting or registered states", ^{ @@ -1289,7 +1321,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onTransportDisconnected]; OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); }); }); @@ -1321,7 +1353,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onError:[OCMArg any]]; OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateReconnecting)); }); it(@"should transition to Reconnecting state if in state registered", ^{ @@ -1334,7 +1366,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onError:[OCMArg any]]; OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateReconnecting)); }); it(@"should stay in the same state if not in the connecting or registered states", ^{ @@ -1347,7 +1379,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onError:[OCMArg any]]; OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateConfigured)); }); }); @@ -1373,12 +1405,9 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve it(@"should return early if the secondary transport has not yet been established", ^{ manager.secondaryTransport = nil; - waitUntilTimeout(1, ^(void (^done)(void)){ - dispatch_sync(testStateMachineQueue, ^{ - [manager disconnectSecondaryTransportWithCompletionHandler:^{ - done(); - }]; - }); + dispatch_sync(testStateMachineQueue, ^{ + [manager disconnectSecondaryTransportWithCompletionHandler:^{ + }]; }); }); @@ -1386,16 +1415,13 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve manager.secondaryTransport = mockSecondaryTransport; OCMExpect([mockSecondaryTransport disconnectWithCompletionHandler:[OCMArg invokeBlock]]); - waitUntilTimeout(1, ^(void (^done)(void)){ - dispatch_sync(testStateMachineQueue, ^{ - [manager disconnectSecondaryTransportWithCompletionHandler:^{\ - expect(manager.secondaryTransport).to(beNil()); - expect(manager.secondaryProtocol).to(beNil()); - expect(manager.streamingServiceTransportMap).to(beEmpty()); - OCMVerify([manager.backgroundTaskManager endBackgroundTask]); - done(); - }]; - }); + dispatch_sync(testStateMachineQueue, ^{ + [manager disconnectSecondaryTransportWithCompletionHandler:^{\ + expect(manager.secondaryTransport).to(beNil()); + expect(manager.secondaryProtocol).to(beNil()); + expect(manager.streamingServiceTransportMap).to(beEmpty()); + OCMVerify([manager.backgroundTaskManager endBackgroundTask]); + }]; }); OCMVerifyAllWithDelay(mockSecondaryTransport, 0.5); @@ -1423,13 +1449,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [manager.stateMachine setToState:SDLSecondaryTransportStateRegistered fromOldState:nil callEnterTransition:NO]; OCMExpect([testStreamingProtocolDelegate didUpdateFromOldVideoProtocol:testSecondaryProtocol toNewVideoProtocol:nil fromOldAudioProtocol:testSecondaryProtocol toNewAudioProtocol:nil]); - waitUntilTimeout(1, ^(void (^done)(void)){ - dispatch_sync(testStateMachineQueue, ^{ - [manager stopWithCompletionHandler:^{ - expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); - done(); - }]; - }); + dispatch_sync(testStateMachineQueue, ^{ + [manager stopWithCompletionHandler:^{ + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); + }]; }); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); @@ -1439,13 +1462,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [manager.stateMachine setToState:SDLSecondaryTransportStateStopped fromOldState:nil callEnterTransition:NO]; OCMExpect([testStreamingProtocolDelegate didUpdateFromOldVideoProtocol:[OCMArg any] toNewVideoProtocol:nil fromOldAudioProtocol:[OCMArg any] toNewAudioProtocol:nil]); - waitUntilTimeout(1, ^(void (^done)(void)){ - dispatch_sync(testStateMachineQueue, ^{ - [manager stopWithCompletionHandler:^{ - expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); - done(); - }]; - }); + dispatch_sync(testStateMachineQueue, ^{ + [manager stopWithCompletionHandler:^{ + expect(manager.stateMachine.currentState).to(equal(SDLSecondaryTransportStateStopped)); + }]; }); OCMVerifyAllWithDelay(testStreamingProtocolDelegate, 0.5); diff --git a/SmartDeviceLinkTests/SDLAlertManagerSpec.m b/SmartDeviceLinkTests/SDLAlertManagerSpec.m index a4df0e7f2f..369f3539a2 100644 --- a/SmartDeviceLinkTests/SDLAlertManagerSpec.m +++ b/SmartDeviceLinkTests/SDLAlertManagerSpec.m @@ -19,6 +19,7 @@ #import "SDLSystemCapabilityManager.h" #import "SDLWindowCapability.h" #import "TestConnectionManager.h" +#import "SDLExpect.h" @interface SDLAlertManager() @@ -66,7 +67,7 @@ @interface SDLPresentAlertOperation() testAlertManager = [[SDLAlertManager alloc] initWithConnectionManager:mockConnectionManager fileManager:mockFileManager systemCapabilityManager:mockSystemCapabilityManager permissionManager:mockPermissionManager]; - expect(testAlertManager.transactionQueue.suspended).toEventually(beTrue()); + expect(testAlertManager.transactionQueue.isSuspended).to(beTrue()); }); }); @@ -110,7 +111,7 @@ @interface SDLPresentAlertOperation() testAlertManager = [[SDLAlertManager alloc] initWithConnectionManager:mockConnectionManager fileManager:mockFileManager systemCapabilityManager:mockSystemCapabilityManager permissionManager:mockPermissionManager]; [testAlertManager start]; - expect(testAlertManager.transactionQueue.suspended).toEventually(beFalse()); + expect(testAlertManager.transactionQueue.suspended).to(beFalse()); }); it(@"should not start the transaction queue until the currentWindowCapability has been set", ^{ @@ -120,7 +121,7 @@ @interface SDLPresentAlertOperation() testAlertManager = [[SDLAlertManager alloc] initWithConnectionManager:mockConnectionManager fileManager:mockFileManager systemCapabilityManager:mockSystemCapabilityManager permissionManager:mockPermissionManager]; [testAlertManager start]; - expect(testAlertManager.transactionQueue.suspended).toEventually(beTrue()); + expect(testAlertManager.transactionQueue.suspended).to(beTrue()); }); }); }); @@ -158,8 +159,8 @@ @interface SDLPresentAlertOperation() SDLPresentAlertOperation *presentAlertOp2 = testAlertManager.transactionQueue.operations[1]; expect(presentAlertOp1.isExecuting).to(beTrue()); expect(presentAlertOp2.isExecuting).to(beFalse()); - expect(presentAlertOp1.currentWindowCapability).toEventually(equal(testWindowCapability)); - expect(presentAlertOp2.currentWindowCapability).toEventually(beNil()); + expect(presentAlertOp1.currentWindowCapability).to(equal(testWindowCapability)); + expect(presentAlertOp2.currentWindowCapability).to(beNil()); }); it(@"should start the queue if the new capability is not nil and update the pending operations with the new capability", ^{ @@ -179,15 +180,18 @@ @interface SDLPresentAlertOperation() OCMVerifyAllWithDelay(mockSystemCapabilityManager, 0.5); - expect(testAlertManager.transactionQueue.suspended).toEventually(beFalse()); + expect(testAlertManager.transactionQueue.suspended).to(beFalse()); expect(testAlertManager.transactionQueue.operationCount).to(equal(2)); SDLPresentAlertOperation *presentAlertOp1 = testAlertManager.transactionQueue.operations[0]; SDLPresentAlertOperation *presentAlertOp2 = testAlertManager.transactionQueue.operations[1]; - expect(presentAlertOp1.isExecuting).to(beTrue()); - expect(presentAlertOp2.isExecuting).to(beFalse()); - expect(presentAlertOp2.currentWindowCapability).toEventually(equal(testWindowCapability)); - expect(presentAlertOp1.currentWindowCapability).toEventually(equal(testWindowCapability)); + + [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout expectBlock:^{ + expect(presentAlertOp1.isExecuting).to(beTrue()); + expect(presentAlertOp2.isExecuting).to(beFalse()); + expect(presentAlertOp2.currentWindowCapability).to(equal(testWindowCapability)); + expect(presentAlertOp1.currentWindowCapability).to(equal(testWindowCapability)); + }]; }); }); diff --git a/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m b/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m index 1ae8c65fd0..90c297e629 100644 --- a/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m +++ b/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m @@ -14,6 +14,7 @@ #import "SDLGetAppServiceDataResponse.h" #import "SDLGlobals.h" #import "TestConnectionManager.h" +#import "SDLExpect.h" QuickSpecBegin(SDLAsynchronousRPCOperationSpec) @@ -42,7 +43,8 @@ testOperation = [[SDLAsynchronousRPCOperation alloc] initWithConnectionManager:testConnectionManager rpc:sendRPC]; [testOperationQueue addOperation:testOperation]; - expect(testConnectionManager.receivedRequests).toEventually(contain(sendRPC)); + sleep(SDLExpect.timeout); + expect(testConnectionManager.receivedRequests).to(contain(sendRPC)); }); }); @@ -63,8 +65,12 @@ [testOperationQueue addOperation:testOperation]; } - expect(testConnectionManager.receivedRequests.count).toEventually(equal(rpcCount)); - expect(testConnectionManager.receivedRequests).toEventually(equal(sendRPCs)); +// sleep(SDLExpect.timeout); +// [SDLExpect SDLExpectWithTimeout:SDLExpect.timeout expectBlock:^{ + [NSThread sleepForTimeInterval:0.5]; + expect(testConnectionManager.receivedRequests.count).to(equal(rpcCount)); + expect(testConnectionManager.receivedRequests).to(equal(sendRPCs)); +// }]; }); }); @@ -83,7 +89,7 @@ [testOperationQueue cancelAllOperations]; [testOperationQueue setSuspended:NO]; - expect(testConnectionManager.receivedRequests).withTimeout(3.0).toEventually(beEmpty()); + expect(testConnectionManager.receivedRequests).withTimeout(3.0).to(beEmpty()); }); }); }); diff --git a/SmartDeviceLinkTests/SDLCacheFileManagerSpec.m b/SmartDeviceLinkTests/SDLCacheFileManagerSpec.m index 836a0391fc..05832a9532 100644 --- a/SmartDeviceLinkTests/SDLCacheFileManagerSpec.m +++ b/SmartDeviceLinkTests/SDLCacheFileManagerSpec.m @@ -147,8 +147,8 @@ - (void)sdl_downloadIconFromRequestURL:(NSString *)requestURL withCompletionHand }); it(@"it should return downloaded image and no error", ^{ - expect(resultImage).toEventually(equal(testImage)); - expect(resultError).toEventually(beNil()); + expect(resultImage).to(equal(testImage)); + expect(resultError).to(beNil()); }); }); @@ -165,8 +165,8 @@ - (void)sdl_downloadIconFromRequestURL:(NSString *)requestURL withCompletionHand }); it(@"it should return downloaded image and no error", ^{ - expect(resultImage).toEventually(equal(testImage)); - expect(resultError).toEventually(beNil()); + expect(resultImage).to(equal(testImage)); + expect(resultError).to(beNil()); }); }); diff --git a/SmartDeviceLinkTests/SDLCarWindowSpec.m b/SmartDeviceLinkTests/SDLCarWindowSpec.m index f90dd4d539..617aca456e 100644 --- a/SmartDeviceLinkTests/SDLCarWindowSpec.m +++ b/SmartDeviceLinkTests/SDLCarWindowSpec.m @@ -75,7 +75,7 @@ - (CVPixelBufferPoolRef)pixelBufferPool { carWindow.rootViewController = rootViewController; it(@"make sure object created and all set", ^{ expect(carWindow).toNot(beNil()); - expect(carWindow.rootViewController).toEventually(equal(rootViewController)); + expect(carWindow.rootViewController).to(equal(rootViewController)); }); }); @@ -86,7 +86,7 @@ - (CVPixelBufferPoolRef)pixelBufferPool { carWindow.rootViewController = rootViewController; it(@"make sure object created and all set", ^{ expect(carWindow).toNot(beNil()); - expect(carWindow.rootViewController).toEventually(equal(rootViewController)); + expect(carWindow.rootViewController).to(equal(rootViewController)); }); }); diff --git a/SmartDeviceLinkTests/SDLExpect.h b/SmartDeviceLinkTests/SDLExpect.h new file mode 100644 index 0000000000..12ecc2d3c7 --- /dev/null +++ b/SmartDeviceLinkTests/SDLExpect.h @@ -0,0 +1,25 @@ +// +// SDLExpect.h +// SmartDeviceLinkTests +// +// Created by Frank Elias on 6/13/23. +// Copyright © 2023 smartdevicelink. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +typedef void (^ ExpectBlock)(void); + +@interface SDLExpect : NSObject + +#define sdlExp(timeout, expectBlock) [SDLExpect SDLExpectWithTimeout timeout:timeout expectBlock:expectBlock)] + ++ (void)SDLExpectWithTimeout:(NSTimeInterval)timeout expectBlock:(ExpectBlock)expectBlock; ++ (BOOL)getVerifiedVal:(BOOL)value; ++ (int)timeout; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLinkTests/SDLExpect.m b/SmartDeviceLinkTests/SDLExpect.m new file mode 100644 index 0000000000..69def089c4 --- /dev/null +++ b/SmartDeviceLinkTests/SDLExpect.m @@ -0,0 +1,26 @@ +// +// SDLExpect.m +// SmartDeviceLinkTests +// +// Created by Frank Elias on 6/13/23. +// Copyright © 2023 smartdevicelink. All rights reserved. +// + +#import "SDLExpect.h" + +@implementation SDLExpect + ++ (void)SDLExpectWithTimeout:(NSTimeInterval)timeout expectBlock:(nonnull ExpectBlock)expectBlock { + [NSTimer scheduledTimerWithTimeInterval:timeout repeats:NO block:^(NSTimer * _Nonnull timer) { + expectBlock(); + }]; +} + ++ (BOOL)getVerifiedVal:(BOOL)value { + usleep(10); + return value; +} + ++ (int) timeout { return 3; } + +@end diff --git a/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m b/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m index 4173b923d1..74793b84bc 100644 --- a/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m +++ b/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m @@ -9,6 +9,7 @@ #import #import #import +#import "SDLExpect.h" #import "SDLAlert.h" #import "SDLAlertResponse.h" @@ -735,9 +736,9 @@ - (SDLAlert *)alertRPC; [testPresentAlertOperation start]; - expect(testPresentAlertOperation.internalError).toEventually(equal([NSError sdl_alertManager_alertDataInvalid])); - expect(hasCalledOperationCompletionHandler).toEventually(beTrue()); - expect(testPresentAlertOperation.isFinished).toEventually(beTrue()); + expect(testPresentAlertOperation.internalError).to(equal([NSError sdl_alertManager_alertDataInvalid])); + expect(hasCalledOperationCompletionHandler).to(beTrue()); + expect(testPresentAlertOperation.isFinished).to(beTrue()); }); }); @@ -759,7 +760,7 @@ - (SDLAlert *)alertRPC; expect(testPresentAlertOperation.internalError).to(equal([NSError sdl_alertManager_alertAudioFileNotSupported])); expect(hasCalledOperationCompletionHandler).to(beTrue()); - expect(testPresentAlertOperation.isFinished).toEventually(beTrue()); + expect(testPresentAlertOperation.isFinished).to(beTrue()); }); it(@"should return an error if invalid data was set", ^{ @@ -775,7 +776,7 @@ - (SDLAlert *)alertRPC; expect(testPresentAlertOperation.internalError).to(equal([NSError sdl_alertManager_alertDataInvalid])); expect(hasCalledOperationCompletionHandler).to(beTrue()); - expect(testPresentAlertOperation.isFinished).toEventually(beTrue()); + expect(testPresentAlertOperation.isFinished).to(beTrue()); }); }); }); @@ -836,7 +837,7 @@ - (SDLAlert *)alertRPC; [testPresentAlertOperation start]; - OCMVerifyAllWithDelay(mockConnectionManager, 1.0); + [SDLExpect SDLExpectWithTimeout:4.0 expectBlock:^{ OCMVerifyAll(mockConnectionManager); }]; }); }); @@ -887,7 +888,7 @@ - (SDLAlert *)alertRPC; [testPresentAlertOperation start]; - OCMVerifyAllWithDelay(mockConnectionManager, 0.5); + [SDLExpect SDLExpectWithTimeout:4.0 expectBlock:^{ OCMVerifyAll(mockConnectionManager); }]; }); }); @@ -953,7 +954,7 @@ - (SDLAlert *)alertRPC; expect(testPresentAlertOperation.internalError).to(beNil()); expect(hasCalledOperationCompletionHandler).to(beTrue()); - expect(testPresentAlertOperation.isFinished).toEventually(beTrue()); + expect(testPresentAlertOperation.isFinished).to(beTrue()); OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); }); @@ -971,11 +972,12 @@ - (SDLAlert *)alertRPC; [testPresentAlertOperation start]; - expect(testPresentAlertOperation.internalError).toEventually(beNil()); - expect(hasCalledOperationCompletionHandler).toEventually(beTrue()); - expect(testPresentAlertOperation.isFinished).toEventually(beTrue()); + [NSThread sleepForTimeInterval:1.0]; - OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + expect(testPresentAlertOperation.internalError).to(beNil()); + expect(hasCalledOperationCompletionHandler).to(beTrue()); + expect(testPresentAlertOperation.isFinished).to(beTrue()); + OCMVerifyAll(mockConnectionManager); }); it(@"should save the error, call the completion handler and finish the operation after an unsuccessful alert response", ^{ @@ -989,11 +991,12 @@ - (SDLAlert *)alertRPC; [testPresentAlertOperation start]; - expect(testPresentAlertOperation.internalError.userInfo[@"tryAgainTime"]).toEventually(equal(response.tryAgainTime)); - expect(testPresentAlertOperation.internalError.userInfo[@"error"]).toEventually(equal(defaultError)); - expect(hasCalledOperationCompletionHandler).toEventually(beTrue()); - expect(testPresentAlertOperation.isFinished).toEventually(beTrue()); + [NSThread sleepForTimeInterval:1.0]; + expect(testPresentAlertOperation.internalError.userInfo[@"tryAgainTime"]).to(equal(response.tryAgainTime)); + expect(testPresentAlertOperation.internalError.userInfo[@"error"]).to(equal(defaultError)); + expect(hasCalledOperationCompletionHandler).to(beTrue()); + expect(testPresentAlertOperation.isFinished).to(beTrue()); OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); }); }); @@ -1031,6 +1034,8 @@ - (SDLAlert *)alertRPC; }] withResponseHandler:[OCMArg any]]); [testPresentAlertOperation start]; + [NSThread sleepForTimeInterval:1.0]; + OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); expect(testPresentAlertOperation.isExecuting).to(beTrue()); expect(testPresentAlertOperation.isFinished).to(beFalse()); @@ -1046,7 +1051,9 @@ - (SDLAlert *)alertRPC; [testCancelAlertView cancel]; - OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + [NSTimer scheduledTimerWithTimeInterval:4.0 repeats:NO block:^(NSTimer * _Nonnull timer) { + OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + }]; }); context(@"If the cancel interaction was successful", ^{ @@ -1054,8 +1061,7 @@ - (SDLAlert *)alertRPC; OCMExpect([strictMockConnectionManager sendConnectionRequest:[OCMArg isKindOfClass:SDLAlert.class] withResponseHandler:[OCMArg any]]); [testPresentAlertOperation start]; - OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); - + OCMVerifyAllWithDelay(strictMockConnectionManager, 1.0); SDLCancelInteractionResponse *testResponse = [[SDLCancelInteractionResponse alloc] init]; testResponse.success = @YES; testResponse.resultCode = SDLResultSuccess; @@ -1073,8 +1079,10 @@ - (SDLAlert *)alertRPC; OCMExpect([strictMockConnectionManager sendConnectionRequest:[OCMArg isKindOfClass:SDLAlert.class] withResponseHandler:[OCMArg any]]); [testPresentAlertOperation start]; - OCMVerifyAllWithDelay(strictMockConnectionManager, 1.0); - + [NSTimer scheduledTimerWithTimeInterval:4.0 repeats:NO block:^(NSTimer * _Nonnull timer) { + OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + }]; + SDLCancelInteractionResponse *testResponse = [[SDLCancelInteractionResponse alloc] init]; testResponse.success = @NO; testResponse.resultCode = SDLResultAborted; @@ -1085,6 +1093,7 @@ - (SDLAlert *)alertRPC; [testCancelAlertView cancel]; OCMVerifyAllWithDelay(strictMockConnectionManager, 1.0); + sleep(1.0); expect(testPresentAlertOperation.error).to(equal(defaultError)); }); }); @@ -1109,7 +1118,9 @@ - (SDLAlert *)alertRPC; OCMExpect([strictMockConnectionManager sendConnectionRequest:[OCMArg isKindOfClass:SDLAlert.class] withResponseHandler:[OCMArg any]]); [testPresentAlertOperation start]; - OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + [NSTimer scheduledTimerWithTimeInterval:4.0 repeats:NO block:^(NSTimer * _Nonnull timer) { + OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + }]; [testPresentAlertOperation cancel]; @@ -1117,7 +1128,9 @@ - (SDLAlert *)alertRPC; [testCancelAlertView cancel]; - OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + [NSTimer scheduledTimerWithTimeInterval:4.0 repeats:NO block:^(NSTimer * _Nonnull timer) { + OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + }]; }); }); @@ -1135,8 +1148,10 @@ - (SDLAlert *)alertRPC; OCMExpect([strictMockConnectionManager sendConnectionRequest:[OCMArg isKindOfClass:SDLAlert.class] withResponseHandler:[OCMArg any]]); [testPresentAlertOperation start]; - OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); - + [NSTimer scheduledTimerWithTimeInterval:4.0 repeats:NO block:^(NSTimer * _Nonnull timer) { + OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + }]; + [testPresentAlertOperation cancel]; OCMReject([mockConnectionManager sendConnectionRequest:[OCMArg isKindOfClass:SDLCancelInteraction.class] withResponseHandler:[OCMArg any]]); @@ -1146,7 +1161,9 @@ - (SDLAlert *)alertRPC; [testPresentAlertOperation start]; [testCancelAlertView cancel]; - OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + [NSTimer scheduledTimerWithTimeInterval:4.0 repeats:NO block:^(NSTimer * _Nonnull timer) { + OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + }]; }); }); }); @@ -1161,7 +1178,9 @@ - (SDLAlert *)alertRPC; OCMExpect([strictMockConnectionManager sendConnectionRequest:[OCMArg isKindOfClass:SDLAlert.class] withResponseHandler:[OCMArg any]]); [testPresentAlertOperation start]; - OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + [NSTimer scheduledTimerWithTimeInterval:4.0 repeats:NO block:^(NSTimer * _Nonnull timer) { + OCMVerifyAllWithDelay(strictMockConnectionManager, 0.5); + }]; OCMReject([strictMockConnectionManager sendConnectionRequest:[OCMArg isKindOfClass:SDLCancelInteraction.class] withResponseHandler:[OCMArg any]]); diff --git a/SmartDeviceLinkTests/SDLStreamingMediaManagerSpec.m b/SmartDeviceLinkTests/SDLStreamingMediaManagerSpec.m index a1620fd3c3..d03d945ca3 100644 --- a/SmartDeviceLinkTests/SDLStreamingMediaManagerSpec.m +++ b/SmartDeviceLinkTests/SDLStreamingMediaManagerSpec.m @@ -248,10 +248,10 @@ - (void)didUpdateFromOldVideoProtocol:(nullable SDLProtocol *)oldVideoProtocol t OCMVerifyAllWithDelay(mockVideoLifecycleManager, 0.5); OCMVerifyAllWithDelay(mockSecondaryTransportManager, 0.5); - expect(testStreamingMediaManager.audioStarted).toEventually(beTrue()); - expect(testStreamingMediaManager.videoStarted).toEventually(beTrue()); - expect(testStreamingMediaManager.audioProtocol).toEventually(equal(mockNewProtocol)); - expect(testStreamingMediaManager.videoProtocol).toEventually(equal(mockNewProtocol)); + expect(testStreamingMediaManager.audioStarted).to(beTrue()); + expect(testStreamingMediaManager.videoStarted).to(beTrue()); + expect(testStreamingMediaManager.audioProtocol).to(equal(mockNewProtocol)); + expect(testStreamingMediaManager.videoProtocol).to(equal(mockNewProtocol)); }); }); @@ -269,10 +269,10 @@ - (void)didUpdateFromOldVideoProtocol:(nullable SDLProtocol *)oldVideoProtocol t OCMVerifyAllWithDelay(mockVideoLifecycleManager, 0.5); OCMVerifyAllWithDelay(mockSecondaryTransportManager, 0.5); - expect(testStreamingMediaManager.audioStarted).toEventually(beFalse()); - expect(testStreamingMediaManager.videoStarted).toEventually(beFalse()); - expect(testStreamingMediaManager.audioProtocol).toEventually(beNil()); - expect(testStreamingMediaManager.videoProtocol).toEventually(beNil()); + expect(testStreamingMediaManager.audioStarted).to(beFalse()); + expect(testStreamingMediaManager.videoStarted).to(beFalse()); + expect(testStreamingMediaManager.audioProtocol).to(beNil()); + expect(testStreamingMediaManager.videoProtocol).to(beNil()); }); }); @@ -298,10 +298,10 @@ - (void)didUpdateFromOldVideoProtocol:(nullable SDLProtocol *)oldVideoProtocol t OCMVerifyAllWithDelay(mockVideoLifecycleManager, 0.5); OCMVerifyAllWithDelay(mockSecondaryTransportManager, 0.5); - expect(testStreamingMediaManager.audioStarted).toEventually(beTrue()); - expect(testStreamingMediaManager.videoStarted).toEventually(beTrue()); - expect(testStreamingMediaManager.audioProtocol).toEventually(equal(mockNewAudioProtocol)); - expect(testStreamingMediaManager.videoProtocol).toEventually(equal(mockNewVideoProtocol)); + expect(testStreamingMediaManager.audioStarted).to(beTrue()); + expect(testStreamingMediaManager.videoStarted).to(beTrue()); + expect(testStreamingMediaManager.audioProtocol).to(equal(mockNewAudioProtocol)); + expect(testStreamingMediaManager.videoProtocol).to(equal(mockNewVideoProtocol)); }); }); @@ -325,10 +325,10 @@ - (void)didUpdateFromOldVideoProtocol:(nullable SDLProtocol *)oldVideoProtocol t OCMVerifyAllWithDelay(mockVideoLifecycleManager, 0.5); OCMVerifyAllWithDelay(mockSecondaryTransportManager, 0.5); - expect(testStreamingMediaManager.videoStarted).toEventually(beTrue()); - expect(testStreamingMediaManager.audioStarted).toEventually(beFalse()); - expect(testStreamingMediaManager.audioProtocol).toEventually(beNil()); - expect(testStreamingMediaManager.videoProtocol).toEventually(equal(mockNewProtocol)); + expect(testStreamingMediaManager.videoStarted).to(beTrue()); + expect(testStreamingMediaManager.audioStarted).to(beFalse()); + expect(testStreamingMediaManager.audioProtocol).to(beNil()); + expect(testStreamingMediaManager.videoProtocol).to(equal(mockNewProtocol)); }); }); @@ -352,10 +352,10 @@ - (void)didUpdateFromOldVideoProtocol:(nullable SDLProtocol *)oldVideoProtocol t OCMVerifyAllWithDelay(mockVideoLifecycleManager, 0.5); OCMVerifyAllWithDelay(mockSecondaryTransportManager, 0.5); - expect(testStreamingMediaManager.videoStarted).toEventually(beFalse()); - expect(testStreamingMediaManager.audioStarted).toEventually(beTrue()); - expect(testStreamingMediaManager.audioProtocol).toEventually(equal(mockNewProtocol)); - expect(testStreamingMediaManager.videoProtocol).toEventually(beNil()); + expect(testStreamingMediaManager.videoStarted).to(beFalse()); + expect(testStreamingMediaManager.audioStarted).to(beTrue()); + expect(testStreamingMediaManager.audioProtocol).to(equal(mockNewProtocol)); + expect(testStreamingMediaManager.videoProtocol).to(beNil()); }); }); }); diff --git a/SmartDeviceLinkTests/SDLSubscribeButtonManagerSpec.m b/SmartDeviceLinkTests/SDLSubscribeButtonManagerSpec.m index 55151ad058..e374c45095 100644 --- a/SmartDeviceLinkTests/SDLSubscribeButtonManagerSpec.m +++ b/SmartDeviceLinkTests/SDLSubscribeButtonManagerSpec.m @@ -125,12 +125,12 @@ @interface SDLSubscribeButtonManager() expect(subscriptionID2).toNot(beNil()); NSArray *observers = testManager.subscribeButtonObservers[testButtonName]; - expect(observers.count).toEventually(equal(2)); - expect((id)observers[0].updateBlock).toEventually(equal((id)testUpdateHandler1)); - expect((id)observers[1].updateBlock).toEventually(equal((id)testUpdateHandler2)); + expect(observers.count).to(equal(2)); + expect((id)observers[0].updateBlock).to(equal((id)testUpdateHandler1)); + expect((id)observers[1].updateBlock).to(equal((id)testUpdateHandler2)); - expect(testConnectionManager.receivedRequests.count).toEventually(equal(1)); - expect(testConnectionManager.receivedRequests[0]).toEventually(beAKindOf(SDLSubscribeButton.class)); + expect(testConnectionManager.receivedRequests.count).to(equal(1)); + expect(testConnectionManager.receivedRequests[0]).to(beAKindOf(SDLSubscribeButton.class)); }); it(@"should send two subscription request for the same button name to the module if the second request is sent before the module responds to the first request and it should add both observers if the second request fails with a result code of IGNORED", ^{ @@ -150,11 +150,11 @@ @interface SDLSubscribeButtonManager() // Both observers should be added NSArray *observers = testManager.subscribeButtonObservers[testButtonName]; - expect(observers.count).toEventually(equal(2)); + expect(observers.count).to(equal(2)); - expect(testConnectionManager.receivedRequests.count).toEventually(equal(2)); - expect(testConnectionManager.receivedRequests[0]).toEventually(beAKindOf(SDLSubscribeButton.class)); - expect(testConnectionManager.receivedRequests[1]).toEventually(beAKindOf(SDLSubscribeButton.class)); + expect(testConnectionManager.receivedRequests.count).to(equal(2)); + expect(testConnectionManager.receivedRequests[0]).to(beAKindOf(SDLSubscribeButton.class)); + expect(testConnectionManager.receivedRequests[1]).to(beAKindOf(SDLSubscribeButton.class)); }); it(@"should not notify the observer when a success response is received for the subscribe button request", ^{ @@ -339,15 +339,15 @@ @interface SDLSubscribeButtonManager() it(@"should notify block handler and observer/selector subscribers when a button event notification is received", ^{ [[NSNotificationCenter defaultCenter] postNotification:buttonEventNotification]; - expect(testHandler1Called).toEventually(beTrue()); - expect(testHandle1Error).toEventually(beNil()); - expect(testHandler1OnButtonEvent).toEventually(equal(testButtonEvent)); - expect(testHandler1OnButtonPress).toEventually(beNil()); + expect(testHandler1Called).to(beTrue()); + expect(testHandle1Error).to(beNil()); + expect(testHandler1OnButtonEvent).to(equal(testButtonEvent)); + expect(testHandler1OnButtonPress).to(beNil()); - expect(testHandler2Called).toEventually(beTrue()); - expect(testHandler2Error).toEventually(beNil()); - expect(testHandler2OnButtonEvent).toEventually(equal(testButtonEvent)); - expect(testHandler2OnButtonPress).toEventually(beNil()); + expect(testHandler2Called).to(beTrue()); + expect(testHandler2Error).to(beNil()); + expect(testHandler2OnButtonEvent).to(equal(testButtonEvent)); + expect(testHandler2OnButtonPress).to(beNil()); expect(testObserver1.buttonNamesReceived.count).to(equal(1)); expect(testObserver1.buttonErrorsReceived).to(beEmpty()); @@ -363,15 +363,15 @@ @interface SDLSubscribeButtonManager() it(@"should notify block handler and observer/selector subscribers when a button press notification is received", ^{ [[NSNotificationCenter defaultCenter] postNotification:buttonPressNotification]; - expect(testHandler1Called).toEventually(beTrue()); - expect(testHandle1Error).toEventually(beNil()); - expect(testHandler1OnButtonEvent).toEventually(beNil()); - expect(testHandler1OnButtonPress).toEventually(equal(testButtonPress)); + expect(testHandler1Called).to(beTrue()); + expect(testHandle1Error).to(beNil()); + expect(testHandler1OnButtonEvent).to(beNil()); + expect(testHandler1OnButtonPress).to(equal(testButtonPress)); - expect(testHandler2Called).toEventually(beTrue()); - expect(testHandler2Error).toEventually(beNil()); - expect(testHandler2OnButtonEvent).toEventually(beNil()); - expect(testHandler2OnButtonPress).toEventually(equal(testButtonPress)); + expect(testHandler2Called).to(beTrue()); + expect(testHandler2Error).to(beNil()); + expect(testHandler2OnButtonEvent).to(beNil()); + expect(testHandler2OnButtonPress).to(equal(testButtonPress)); expect(testObserver1.buttonNamesReceived.count).to(equal(1)); expect(testObserver1.buttonErrorsReceived).to(beEmpty()); diff --git a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m index 5343c43970..d3845996c0 100644 --- a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m +++ b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m @@ -856,7 +856,7 @@ @interface SDLSystemCapabilityManager () }); it(@"should properly update phone capability", ^{ - expect(testSystemCapabilityManager.phoneCapability).toEventually(equal(phoneCapability)); + expect(testSystemCapabilityManager.phoneCapability).to(equal(phoneCapability)); }); }); @@ -914,18 +914,18 @@ @interface SDLSystemCapabilityManager () }); it(@"should not notify subscribers of new data because it was sent outside of the SCM", ^{ - expect(handlerTriggeredCount).toEventually(equal(1)); + expect(handlerTriggeredCount).to(equal(1)); - expect(phoneObserver.selectorCalledCount).toEventually(equal(0)); - expect(navigationObserver.selectorCalledCount).toEventually(equal(0)); + expect(phoneObserver.selectorCalledCount).to(equal(0)); + expect(navigationObserver.selectorCalledCount).to(equal(0)); - expect(videoStreamingObserver.selectorCalledCount).toEventually(equal(0)); - expect(videoStreamingObserver.subscribedValuesReceived).toEventually(haveCount(0)); - expect(videoStreamingObserver.subscribedValuesReceived.firstObject).toEventually(beNil()); + expect(videoStreamingObserver.selectorCalledCount).to(equal(0)); + expect(videoStreamingObserver.subscribedValuesReceived).to(haveCount(0)); + expect(videoStreamingObserver.subscribedValuesReceived.firstObject).to(beNil()); - expect(displaysObserver.selectorCalledCount).toEventually(equal(1)); - expect(displaysObserver.subscribedValuesReceived).toEventually(haveCount(1)); - expect(displaysObserver.subscribedValuesReceived.firstObject).toEventually(beTrue()); + expect(displaysObserver.selectorCalledCount).to(equal(1)); + expect(displaysObserver.subscribedValuesReceived).to(haveCount(1)); + expect(displaysObserver.subscribedValuesReceived.firstObject).to(beTrue()); }); describe(@"unsubscribing", ^{ @@ -941,13 +941,13 @@ @interface SDLSystemCapabilityManager () }); it(@"should not notify the subscriber of the new data", ^{ - expect(handlerTriggeredCount).toEventually(equal(1)); + expect(handlerTriggeredCount).to(equal(1)); - expect(phoneObserver.selectorCalledCount).toEventually(equal(0)); // No change from above - expect(navigationObserver.selectorCalledCount).toEventually(equal(0)); - expect(videoStreamingObserver.selectorCalledCount).toEventually(equal(0)); + expect(phoneObserver.selectorCalledCount).to(equal(0)); // No change from above + expect(navigationObserver.selectorCalledCount).to(equal(0)); + expect(videoStreamingObserver.selectorCalledCount).to(equal(0)); - expect(displaysObserver.selectorCalledCount).toEventually(equal(1)); + expect(displaysObserver.selectorCalledCount).to(equal(1)); }); }); }); @@ -967,18 +967,18 @@ @interface SDLSystemCapabilityManager () }); it(@"should notify subscribers of the new data", ^{ - expect(handlerTriggeredCount).toEventually(equal(2)); + expect(handlerTriggeredCount).to(equal(2)); - expect(phoneObserver.selectorCalledCount).toEventually(equal(1)); - expect(navigationObserver.selectorCalledCount).toEventually(equal(0)); + expect(phoneObserver.selectorCalledCount).to(equal(1)); + expect(navigationObserver.selectorCalledCount).to(equal(0)); - expect(videoStreamingObserver.selectorCalledCount).toEventually(equal(0)); - expect(videoStreamingObserver.subscribedValuesReceived).toEventually(haveCount(0)); - expect(videoStreamingObserver.subscribedValuesReceived.firstObject).toEventually(beNil()); + expect(videoStreamingObserver.selectorCalledCount).to(equal(0)); + expect(videoStreamingObserver.subscribedValuesReceived).to(haveCount(0)); + expect(videoStreamingObserver.subscribedValuesReceived.firstObject).to(beNil()); - expect(displaysObserver.selectorCalledCount).toEventually(equal(1)); - expect(displaysObserver.subscribedValuesReceived).toEventually(haveCount(1)); - expect(displaysObserver.subscribedValuesReceived.firstObject).toEventually(beTrue()); + expect(displaysObserver.selectorCalledCount).to(equal(1)); + expect(displaysObserver.subscribedValuesReceived).to(haveCount(1)); + expect(displaysObserver.subscribedValuesReceived.firstObject).to(beTrue()); }); describe(@"unsubscribing", ^{ @@ -993,10 +993,10 @@ @interface SDLSystemCapabilityManager () }); it(@"should not notify the subscriber of the new data", ^{ - expect(phoneObserver.selectorCalledCount).toEventually(equal(1)); // No change from above - expect(navigationObserver.selectorCalledCount).toEventually(equal(0)); - expect(videoStreamingObserver.selectorCalledCount).toEventually(equal(0)); - expect(displaysObserver.selectorCalledCount).toEventually(equal(1)); + expect(phoneObserver.selectorCalledCount).to(equal(1)); // No change from above + expect(navigationObserver.selectorCalledCount).to(equal(0)); + expect(videoStreamingObserver.selectorCalledCount).to(equal(0)); + expect(displaysObserver.selectorCalledCount).to(equal(1)); }); }); }); diff --git a/SmartDeviceLinkTests/TransportSpecs/TCP/SDLTCPTransportSpec.m b/SmartDeviceLinkTests/TransportSpecs/TCP/SDLTCPTransportSpec.m index a23fec3e5c..7ef0b0206c 100644 --- a/SmartDeviceLinkTests/TransportSpecs/TCP/SDLTCPTransportSpec.m +++ b/SmartDeviceLinkTests/TransportSpecs/TCP/SDLTCPTransportSpec.m @@ -72,15 +72,11 @@ @interface SDLTCPTransport () expect(transport.inputStream != nil); expect(transport.outputStream != nil); - waitUntilTimeout(1, ^(void (^done)(void)){ - [transport disconnectWithCompletionHandler:^{ - expect(transport.ioThread.isCancelled).to(beTrue()); - expect(transport.inputStream).to(beNil()); - expect(transport.outputStream).to(beNil()); - - done(); - }]; - }); + [transport disconnectWithCompletionHandler:^{ + expect(transport.ioThread.isCancelled).to(beTrue()); + expect(transport.inputStream).to(beNil()); + expect(transport.outputStream).to(beNil()); + }]; }); it(@"Should invoke onError delegate when connection is refused", ^ { @@ -104,15 +100,11 @@ @interface SDLTCPTransport () OCMVerifyAllWithDelay(transportDelegateMock, 0.5); - waitUntilTimeout(1, ^(void (^done)(void)){ - [transport disconnectWithCompletionHandler:^{ - expect(transport.ioThread.isCancelled).to(beTrue()); - expect(transport.inputStream).to(beNil()); - expect(transport.outputStream).to(beNil()); - - done(); - }]; - }); + [transport disconnectWithCompletionHandler:^{ + expect(transport.ioThread.isCancelled).to(beTrue()); + expect(transport.inputStream).to(beNil()); + expect(transport.outputStream).to(beNil()); + }]; }); it(@"Should invoke onError delegate when connection is timed out", ^ { @@ -130,15 +122,11 @@ @interface SDLTCPTransport () // timeout value should be longer than 'ConnectionTimeoutSecs' in SDLTCPTransport OCMVerifyAllWithDelay(transportDelegateMock, 30.5); - waitUntilTimeout(1, ^(void (^done)(void)){ - [transport disconnectWithCompletionHandler:^{ - expect(transport.ioThread.isCancelled).to(beTrue()); - expect(transport.inputStream).to(beNil()); - expect(transport.outputStream).to(beNil()); - - done(); - }]; - }); + [transport disconnectWithCompletionHandler:^{ + expect(transport.ioThread.isCancelled).to(beTrue()); + expect(transport.inputStream).to(beNil()); + expect(transport.outputStream).to(beNil()); + }]; }); it(@"Should invoke onError delegate when input parameter is invalid", ^ { @@ -155,15 +143,11 @@ @interface SDLTCPTransport () OCMVerifyAllWithDelay(transportDelegateMock, 0.5); - waitUntilTimeout(1, ^(void (^done)(void)){ - [transport disconnectWithCompletionHandler:^{ - expect(transport.ioThread.isCancelled).to(beTrue()); - expect(transport.inputStream).to(beNil()); - expect(transport.outputStream).to(beNil()); - - done(); - }]; - }); + [transport disconnectWithCompletionHandler:^{ + expect(transport.ioThread.isCancelled).to(beTrue()); + expect(transport.inputStream).to(beNil()); + expect(transport.outputStream).to(beNil()); + }]; }); it(@"Should send out data when send is called", ^ { @@ -192,15 +176,11 @@ @interface SDLTCPTransport () OCMVerifyAllWithDelay(transportDelegateMock, 0.5); expect([receivedData isEqualToData:testData]); - waitUntilTimeout(1, ^(void (^done)(void)){ - [transport disconnectWithCompletionHandler:^{ - expect(transport.ioThread.isCancelled).to(beTrue()); - expect(transport.inputStream).to(beNil()); - expect(transport.outputStream).to(beNil()); - - done(); - }]; - }); + [transport disconnectWithCompletionHandler:^{ + expect(transport.ioThread.isCancelled).to(beTrue()); + expect(transport.inputStream).to(beNil()); + expect(transport.outputStream).to(beNil()); + }]; }); it(@"Should send out data even if send is called some time after", ^ { @@ -240,15 +220,11 @@ @interface SDLTCPTransport () // don't receive further delegate events server.delegate = nil; - waitUntilTimeout(1, ^(void (^done)(void)){ - [transport disconnectWithCompletionHandler:^{ - expect(transport.ioThread.isCancelled).to(beTrue()); - expect(transport.inputStream).to(beNil()); - expect(transport.outputStream).to(beNil()); - - done(); - }]; - }); + [transport disconnectWithCompletionHandler:^{ + expect(transport.ioThread.isCancelled).to(beTrue()); + expect(transport.inputStream).to(beNil()); + expect(transport.outputStream).to(beNil()); + }]; }); it(@"Should invoke onDataReceived delegate when received some data", ^ { @@ -285,15 +261,11 @@ @interface SDLTCPTransport () OCMVerifyAllWithDelay(transportDelegateMock, 0.5); expect([receivedData isEqualToData:expectedData]); - waitUntilTimeout(1, ^(void (^done)(void)){ - [transport disconnectWithCompletionHandler:^{ - expect(transport.ioThread.isCancelled).to(beTrue()); - expect(transport.inputStream).to(beNil()); - expect(transport.outputStream).to(beNil()); - - done(); - }]; - }); + [transport disconnectWithCompletionHandler:^{ + expect(transport.ioThread.isCancelled).to(beTrue()); + expect(transport.inputStream).to(beNil()); + expect(transport.outputStream).to(beNil()); + }]; }); it(@"Should generate disconnected event after peer closed connection", ^ { @@ -316,15 +288,11 @@ @interface SDLTCPTransport () OCMVerifyAllWithDelay(transportDelegateMock, 0.5); - waitUntilTimeout(1, ^(void (^done)(void)){ - [transport disconnectWithCompletionHandler:^{ - expect(transport.ioThread.isCancelled).to(beTrue()); - expect(transport.inputStream).to(beNil()); - expect(transport.outputStream).to(beNil()); - - done(); - }]; - }); + [transport disconnectWithCompletionHandler:^{ + expect(transport.ioThread.isCancelled).to(beTrue()); + expect(transport.inputStream).to(beNil()); + expect(transport.outputStream).to(beNil()); + }]; }); }); diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m index 42db9c3fcf..ea0b18b052 100644 --- a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m +++ b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m @@ -25,6 +25,7 @@ #import "SDLTouchType.h" #import "SDLTouch.h" #import "SDLVideoStreamingCapability.h" +#import "SDLExpect.h" @interface SDLTouchManager () @@ -69,16 +70,16 @@ + (void)testTouchesWithTimeout:(CGFloat)timeoutTime endPinch:(BOOL)didCallEndPinch expected:(BOOL)expectedDidCallEndPinch cancelPinch:(BOOL)didCallCancelPinch expected:(BOOL)expectedDidCallCancelPinch { - expect(didCallSingleTap).withTimeout(timeoutTime).toEventually(expectedDidCallSingleTap ? beTrue() : beFalse()); - expect(didCallDoubleTap).withTimeout(timeoutTime).toEventually(expectedDidCallDoubleTap ? beTrue() : beFalse()); - expect(didCallBeginPan).withTimeout(timeoutTime).toEventually(expectedDidCallBeginPan ? beTrue() : beFalse()); - expect(didCallMovePan).withTimeout(timeoutTime).toEventually(expectedDidCallMovePan ? beTrue() : beFalse()); - expect(didCallEndPan).withTimeout(timeoutTime).toEventually(expectedDidCallEndPan ? beTrue() : beFalse()); - expect(didCallCancelPan).withTimeout(timeoutTime).toEventually(expectedDidCallCancelPan ? beTrue() : beFalse()); - expect(didCallBeginPinch).withTimeout(timeoutTime).toEventually(expectedDidCallBeginPinch ? beTrue() : beFalse()); - expect(didCallMovePinch).withTimeout(timeoutTime).toEventually(expectedDidCallMovePinch ? beTrue() : beFalse()); - expect(didCallEndPinch).withTimeout(timeoutTime).toEventually(expectedDidCallEndPinch ? beTrue() : beFalse()); - expect(didCallCancelPinch).withTimeout(timeoutTime).toEventually(expectedDidCallCancelPinch ? beTrue() : beFalse()); + expect(didCallSingleTap).withTimeout(timeoutTime).to(expectedDidCallSingleTap ? beTrue() : beFalse()); + expect(didCallDoubleTap).withTimeout(timeoutTime).to(expectedDidCallDoubleTap ? beTrue() : beFalse()); + expect(didCallBeginPan).withTimeout(timeoutTime).to(expectedDidCallBeginPan ? beTrue() : beFalse()); + expect(didCallMovePan).withTimeout(timeoutTime).to(expectedDidCallMovePan ? beTrue() : beFalse()); + expect(didCallEndPan).withTimeout(timeoutTime).to(expectedDidCallEndPan ? beTrue() : beFalse()); + expect(didCallCancelPan).withTimeout(timeoutTime).to(expectedDidCallCancelPan ? beTrue() : beFalse()); + expect(didCallBeginPinch).withTimeout(timeoutTime).to(expectedDidCallBeginPinch ? beTrue() : beFalse()); + expect(didCallMovePinch).withTimeout(timeoutTime).to(expectedDidCallMovePinch ? beTrue() : beFalse()); + expect(didCallEndPinch).withTimeout(timeoutTime).to(expectedDidCallEndPinch ? beTrue() : beFalse()); + expect(didCallCancelPinch).withTimeout(timeoutTime).to(expectedDidCallCancelPinch ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); } @@ -140,7 +141,9 @@ + (void)testTouchesWithTimeout:(CGFloat)timeoutTime __block DelegateCallbackBlock pinchEndTests; __block DelegateCallbackBlock pinchCanceledTests; - __block CGFloat additionalWaitTime = 1.0f; + __block XCTestExpectation *didCallSingleTapExpectation; + + __block CGFloat additionalWaitTime = 5.0f; __block NSUInteger numTimesHandlerCalled; __block NSUInteger expectedNumTimesHandlerCalled; @@ -161,14 +164,18 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent controlPoint = CGPointMake(100, 200); + didCallSingleTapExpectation = [self expectationWithDescription:@"Expectation for the didCallSingleTap test"]; didCallSingleTap = NO; - [[[[delegateMock stub] andDo:^(NSInvocation* invocation) { - didCallSingleTap = YES; - singleTapTests(invocation); - }] ignoringNonObjectArgs] touchManager:[OCMArg any] didReceiveSingleTapForView:[OCMArg any] atPoint:CGPointZero]; - singleTapTests = ^(NSInvocation* invocation) { - failWithMessage(@"Failed to call Single Tap Tests."); - }; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ + [[[[delegateMock stub] andDo:^(NSInvocation* invocation) { + didCallSingleTap = YES; + [didCallSingleTapExpectation fulfill]; + singleTapTests(invocation); + }] ignoringNonObjectArgs] touchManager:[OCMArg any] didReceiveSingleTapForView:[OCMArg any] atPoint:CGPointZero]; + singleTapTests = ^(NSInvocation* invocation) { + failWithMessage(@"Failed to call Single Tap Tests."); + }; + }); didCallDoubleTap = NO; [[[[delegateMock stub] andDo:^(NSInvocation* invocation) { @@ -325,8 +332,8 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent performTouchEvent(touchManager, firstOnTouchEventEnd); expectedDidCallSingleTap = YES; expectedNumTimesHandlerCalled = 2; - expect(didCallSingleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallSingleTap ? beTrue() : beFalse()); - + + expect(didCallSingleTap).to(expectedDidCallSingleTap ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); @@ -345,9 +352,8 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedScaledPoint = CGPointMake(66.666664123535156, 133.33332824707031); expectedDidCallSingleTap = YES; expectedNumTimesHandlerCalled = 2; - - expect(didCallSingleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallSingleTap ? beTrue() : beFalse()); - + + expect(didCallSingleTap).to(expectedDidCallSingleTap ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); @@ -366,10 +372,12 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedScaledPoint = CGPointMake(100, 200); expectedDidCallSingleTap = YES; expectedNumTimesHandlerCalled = 2; - - expect(didCallSingleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallSingleTap ? beTrue() : beFalse()); - - expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + + [SDLExpect SDLExpectWithTimeout:(touchManager.tapTimeThreshold + additionalWaitTime) expectBlock:^{ + sleep(touchManager.tapTimeThreshold + additionalWaitTime); + expect(didCallSingleTap).to(expectedDidCallSingleTap ? beTrue() : beFalse()); + expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + }]; }); it(@"should correctly use a scale of 1 if the scale value is not set", ^{ @@ -385,9 +393,7 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedScaledPoint = CGPointMake(100, 200); expectedDidCallSingleTap = YES; expectedNumTimesHandlerCalled = 2; - - expect(didCallSingleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallSingleTap ? beTrue() : beFalse()); - + expect(didCallSingleTap).to(expectedDidCallSingleTap ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); }); @@ -420,25 +426,29 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent }); it(@"should correctly handle a single tap", ^{ - singleTapTests = ^(NSInvocation* invocation) { - __unsafe_unretained SDLTouchManager* touchManagerCallback; - CGPoint point; - [invocation getArgument:&touchManagerCallback atIndex:2]; - [invocation getArgument:&point atIndex:4]; - - expect(touchManagerCallback).to(equal(touchManager)); - expect(@(CGPointEqualToPoint(point, movePoint))).to(beTruthy()); - }; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ + singleTapTests = ^(NSInvocation* invocation) { + __unsafe_unretained SDLTouchManager* touchManagerCallback; + CGPoint point; + [invocation getArgument:&touchManagerCallback atIndex:2]; + [invocation getArgument:&point atIndex:4]; - performTouchEvent(touchManager, firstOnTouchEventStart); - performTouchEvent(touchManager, firstOnTouchEventMove); - performTouchEvent(touchManager, firstOnTouchEventEnd); + expect(touchManagerCallback).to(equal(touchManager)); + expect(@(CGPointEqualToPoint(point, movePoint))).to(beTruthy()); - expectedDidCallSingleTap = YES; - expectedNumTimesHandlerCalled = 3; + expect(didCallSingleTap).to(expectedDidCallSingleTap ? beTrue() : beFalse()); + expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + }; - expect(didCallSingleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallSingleTap ? beTrue() : beFalse()); - expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + performTouchEvent(touchManager, firstOnTouchEventStart); + performTouchEvent(touchManager, firstOnTouchEventMove); + performTouchEvent(touchManager, firstOnTouchEventEnd); + + expectedDidCallSingleTap = YES; + expectedNumTimesHandlerCalled = 3; + }); + + [self waitForExpectationsWithTimeout:5 handler:nil]; }); }); @@ -494,7 +504,8 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallDoubleTap = YES; expectedNumTimesHandlerCalled = 4; - expect(didCallDoubleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallDoubleTap ? beTrue() : beFalse()); + sleep(touchManager.tapTimeThreshold + additionalWaitTime); + expect(didCallDoubleTap).to(expectedDidCallDoubleTap ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); }); @@ -517,9 +528,11 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallDoubleTap = NO; expectedNumTimesHandlerCalled = 4; - expect(didCallDoubleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallDoubleTap ? beTrue() : beFalse()); - expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + [SDLExpect SDLExpectWithTimeout:(touchManager.tapTimeThreshold + additionalWaitTime) expectBlock:^{ + expect(didCallDoubleTap).to(expectedDidCallDoubleTap ? beTrue() : beFalse()); + expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + }]; }); }); }); @@ -555,9 +568,10 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallSingleTap = NO; expectedNumTimesHandlerCalled = 2; - expect(didCallSingleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallSingleTap ? beTrue() : beFalse()); - - expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + [SDLExpect SDLExpectWithTimeout:(touchManager.tapTimeThreshold + additionalWaitTime) expectBlock:^{ + expect(didCallSingleTap).to(expectedDidCallSingleTap ? beTrue() : beFalse()); + expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + }]; }); }); @@ -590,9 +604,10 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallDoubleTap = NO; expectedNumTimesHandlerCalled = 4; - expect(didCallDoubleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallDoubleTap ? beTrue() : beFalse()); - - expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + [SDLExpect SDLExpectWithTimeout:(touchManager.tapTimeThreshold + additionalWaitTime) expectBlock:^{ + expect(didCallDoubleTap).to(expectedDidCallDoubleTap ? beTrue() : beFalse()); + expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + }]; }); it(@"should not issue delegate callbacks when a double tap is canceled before the start of the second tap", ^{ @@ -605,16 +620,17 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallDoubleTap = NO; expectedNumTimesHandlerCalled = 3; - expect(didCallDoubleTap).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallDoubleTap ? beTrue() : beFalse()); - - expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + [SDLExpect SDLExpectWithTimeout:(touchManager.tapTimeThreshold + additionalWaitTime) expectBlock:^{ + expect(didCallDoubleTap).to(expectedDidCallDoubleTap ? beTrue() : beFalse()); + expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); + }]; }); }); afterEach(^{ - expect(touchManager.previousTouch).toEventually(beNil()); - expect(touchManager.singleTapTouch).toEventually(beNil()); - expect(touchManager.singleTapTimer).toEventually(beNil()); + expect(touchManager.previousTouch).to(beNil()); + expect(touchManager.singleTapTouch).to(beNil()); + expect(touchManager.singleTapTimer).to(beNil()); }); }); }); @@ -761,11 +777,11 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallCancelPan = NO; expectedNumTimesHandlerCalled = 4; - expect(didCallBeginPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallBeginPan ? beTrue() : beFalse()); - expect(didCallMovePan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallMovePan ? beTrue() : beFalse()); - expect(didCallEndPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallEndPan ? beTrue() : beFalse()); - expect(didCallCancelPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallCancelPan ? beTrue() : beFalse()); - + sleep(touchManager.tapTimeThreshold + additionalWaitTime); + expect(didCallBeginPan).to(expectedDidCallBeginPan ? beTrue() : beFalse()); + expect(didCallMovePan).to(expectedDidCallMovePan ? beTrue() : beFalse()); + expect(didCallEndPan).to(expectedDidCallEndPan ? beTrue() : beFalse()); + expect(didCallCancelPan).to(expectedDidCallCancelPan ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); }); @@ -802,11 +818,11 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallCancelPan = YES; expectedNumTimesHandlerCalled = 3; - expect(didCallBeginPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallBeginPan ? beTrue() : beFalse()); - expect(didCallMovePan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallMovePan ? beTrue() : beFalse()); - expect(didCallEndPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallEndPan ? beTrue() : beFalse()); - expect(didCallCancelPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallCancelPan ? beTrue() : beFalse()); - + sleep(touchManager.tapTimeThreshold + additionalWaitTime); + expect(didCallBeginPan).to(expectedDidCallBeginPan ? beTrue() : beFalse()); + expect(didCallMovePan).to(expectedDidCallMovePan ? beTrue() : beFalse()); + expect(didCallEndPan).to(expectedDidCallEndPan ? beTrue() : beFalse()); + expect(didCallCancelPan).to(expectedDidCallCancelPan ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); @@ -856,11 +872,11 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallCancelPan = YES; expectedNumTimesHandlerCalled = 4; - expect(didCallBeginPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallBeginPan ? beTrue() : beFalse()); - expect(didCallMovePan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallMovePan ? beTrue() : beFalse()); - expect(didCallEndPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallEndPan ? beTrue() : beFalse()); - expect(didCallCancelPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallCancelPan ? beTrue() : beFalse()); - + sleep(touchManager.tapTimeThreshold + additionalWaitTime); + expect(didCallBeginPan).to(expectedDidCallBeginPan ? beTrue() : beFalse()); + expect(didCallMovePan).to(expectedDidCallMovePan ? beTrue() : beFalse()); + expect(didCallEndPan).to(expectedDidCallEndPan ? beTrue() : beFalse()); + expect(didCallCancelPan).to(expectedDidCallCancelPan ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); @@ -873,16 +889,16 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallCancelPan = NO; expectedNumTimesHandlerCalled = 1; - expect(didCallBeginPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallBeginPan ? beTrue() : beFalse()); - expect(didCallMovePan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallMovePan ? beTrue() : beFalse()); - expect(didCallEndPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallEndPan ? beTrue() : beFalse()); - expect(didCallCancelPan).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallCancelPan ? beTrue() : beFalse()); - + sleep(touchManager.tapTimeThreshold + additionalWaitTime); + expect(didCallBeginPan).to(expectedDidCallBeginPan ? beTrue() : beFalse()); + expect(didCallMovePan).to(expectedDidCallMovePan ? beTrue() : beFalse()); + expect(didCallEndPan).to(expectedDidCallEndPan ? beTrue() : beFalse()); + expect(didCallCancelPan).to(expectedDidCallCancelPan ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); afterEach(^{ - expect(touchManager.currentPinchGesture).toEventually(beNil()); + expect(touchManager.currentPinchGesture).to(beNil()); }); }); }); @@ -1039,11 +1055,11 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallCancelPinch = NO; expectedNumTimesHandlerCalled = 4; - expect(didCallBeginPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallBeginPinch ? beTrue() : beFalse()); - expect(didCallMovePinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallMovePinch ? beTrue() : beFalse()); - expect(didCallEndPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallEndPinch ? beTrue() : beFalse()); - expect(didCallCancelPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallCancelPinch ? beTrue() : beFalse()); - + sleep(touchManager.tapTimeThreshold + additionalWaitTime); + expect(didCallBeginPinch).to(expectedDidCallBeginPinch ? beTrue() : beFalse()); + expect(didCallMovePinch).to(expectedDidCallMovePinch ? beTrue() : beFalse()); + expect(didCallEndPinch).to(expectedDidCallEndPinch ? beTrue() : beFalse()); + expect(didCallCancelPinch).to(expectedDidCallCancelPinch ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); }); @@ -1097,11 +1113,11 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallCancelPinch = NO; expectedNumTimesHandlerCalled = 4; - expect(didCallBeginPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallBeginPinch ? beTrue() : beFalse()); - expect(didCallMovePinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallMovePinch ? beTrue() : beFalse()); - expect(didCallEndPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallEndPinch ? beTrue() : beFalse()); - expect(didCallCancelPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallCancelPinch ? beTrue() : beFalse()); - + sleep(touchManager.tapTimeThreshold + additionalWaitTime); + expect(didCallBeginPinch).to(expectedDidCallBeginPinch ? beTrue() : beFalse()); + expect(didCallMovePinch).to(expectedDidCallMovePinch ? beTrue() : beFalse()); + expect(didCallEndPinch).to(expectedDidCallEndPinch ? beTrue() : beFalse()); + expect(didCallCancelPinch).to(expectedDidCallCancelPinch ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); }); @@ -1138,10 +1154,14 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallCancelPinch = YES; expectedNumTimesHandlerCalled = 3; - expect(didCallBeginPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallBeginPinch ? beTrue() : beFalse()); - expect(didCallMovePinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallMovePinch ? beTrue() : beFalse()); - expect(didCallEndPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallEndPinch ? beTrue() : beFalse()); - expect(didCallCancelPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallCancelPinch ? beTrue() : beFalse()); + [NSThread sleepForTimeInterval:(touchManager.tapTimeThreshold + additionalWaitTime)]; + + sleep(touchManager.tapTimeThreshold + additionalWaitTime); + + expect(didCallBeginPinch).to(expectedDidCallBeginPinch ? beTrue() : beFalse()); + expect(didCallMovePinch).to(expectedDidCallMovePinch ? beTrue() : beFalse()); + expect(didCallEndPinch).to(expectedDidCallEndPinch ? beTrue() : beFalse()); + expect(didCallCancelPinch).to(expectedDidCallCancelPinch ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); @@ -1192,10 +1212,12 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallCancelPinch = YES; expectedNumTimesHandlerCalled = 4; - expect(didCallBeginPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallBeginPinch ? beTrue() : beFalse()); - expect(didCallMovePinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallMovePinch ? beTrue() : beFalse()); - expect(didCallEndPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallEndPinch ? beTrue() : beFalse()); - expect(didCallCancelPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallCancelPinch ? beTrue() : beFalse()); + [NSThread sleepForTimeInterval:(touchManager.tapTimeThreshold + additionalWaitTime)]; + + expect(didCallBeginPinch).to(expectedDidCallBeginPinch ? beTrue() : beFalse()); + expect(didCallMovePinch).to(expectedDidCallMovePinch ? beTrue() : beFalse()); + expect(didCallEndPinch).to(expectedDidCallEndPinch ? beTrue() : beFalse()); + expect(didCallCancelPinch).to(expectedDidCallCancelPinch ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); @@ -1209,16 +1231,18 @@ __block void (^performTouchEvent)(SDLTouchManager* touchManager, SDLOnTouchEvent expectedDidCallCancelPinch = NO; expectedNumTimesHandlerCalled = 1; - expect(didCallBeginPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallBeginPinch ? beTrue() : beFalse()); - expect(didCallMovePinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallMovePinch ? beTrue() : beFalse()); - expect(didCallEndPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallEndPinch ? beTrue() : beFalse()); - expect(didCallCancelPinch).withTimeout((touchManager.tapTimeThreshold + additionalWaitTime)).toEventually(expectedDidCallCancelPinch ? beTrue() : beFalse()); + [NSThread sleepForTimeInterval:(touchManager.tapTimeThreshold + additionalWaitTime)]; + + expect(didCallBeginPinch).to(expectedDidCallBeginPinch ? beTrue() : beFalse()); + expect(didCallMovePinch).to(expectedDidCallMovePinch ? beTrue() : beFalse()); + expect(didCallEndPinch).to(expectedDidCallEndPinch ? beTrue() : beFalse()); + expect(didCallCancelPinch).to(expectedDidCallCancelPinch ? beTrue() : beFalse()); expect(numTimesHandlerCalled).to(equal(@(expectedNumTimesHandlerCalled))); }); afterEach(^{ - expect(touchManager.currentPinchGesture).toEventually(beNil()); + expect(touchManager.currentPinchGesture).to(beNil()); }); }); });