From 6c4ed92e511cc9e4a22a2fc6c6ad1cf40997b55e Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 3 Mar 2021 10:55:50 -0500 Subject: [PATCH 01/13] Increase the timeout on some tests --- SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m | 5 ++--- .../DevAPISpecs/SDLVoiceCommandManagerSpec.m | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m index 373003311..01eca9a7a 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m @@ -40,12 +40,11 @@ [mockAudioManager clearData]; [testManager playNextWhenReady]; // playNextWhenReady dispatches to a new thread so the test can sometimes fail due to timing issues even when using `toEventually`. - [NSThread sleepForTimeInterval:0.1]; }); it(@"should fail to send data", ^{ - expect(mockAudioManager.dataSinceClear.length).toEventually(equal(0)); - expect(mockAudioManager.error.code).toEventually(equal(SDLAudioStreamManagerErrorNotConnected)); + expect(mockAudioManager.dataSinceClear.length).withTimeout(3.0).toEventually(equal(0)); + expect(mockAudioManager.error.code).withTimeout(3.0).toEventually(equal(SDLAudioStreamManagerErrorNotConnected)); }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m index 58d5ff591..7271889d5 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m @@ -151,7 +151,7 @@ @interface SDLVoiceCommandManager() it(@"should update the second operation", ^{ SDLVoiceCommandUpdateOperation *secondOp = testManager.transactionQueue.operations[0]; - expect(secondOp.oldVoiceCommands.firstObject).toEventually(equal(testVoiceCommand2)); + expect(secondOp.oldVoiceCommands.firstObject).withTimeout(3.0).toEventually(equal(testVoiceCommand2)); }); }); }); From 89ec72be0eb8d2c831a153d5ee62d9ca0a167f1a Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 3 Mar 2021 11:12:12 -0500 Subject: [PATCH 02/13] Update tests to remove many sleep calls --- .../SDLAsynchronousRPCRequestOperationSpec.m | 8 +++----- .../DevAPISpecs/SDLAudioStreamManagerSpec.m | 9 +-------- .../DevAPISpecs/SDLFileManagerSpec.m | 8 +++----- .../DevAPISpecs/SDLLifecycleManagerSpec.m | 6 ++---- .../SDLSequentialRPCRequestOperationSpec.m | 15 ++++++--------- .../DevAPISpecs/SDLSoftButtonManagerSpec.m | 13 ++++++------- .../SDLAsynchronousRPCOperationSpec.m | 6 +----- .../SDLSystemCapabilityManagerSpec.m | 10 +++++----- 8 files changed, 27 insertions(+), 48 deletions(-) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLAsynchronousRPCRequestOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLAsynchronousRPCRequestOperationSpec.m index 9a80d5fd4..8376a8922 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLAsynchronousRPCRequestOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLAsynchronousRPCRequestOperationSpec.m @@ -56,10 +56,9 @@ }]; [testOperationQueue addOperation:testOperation]; - [NSThread sleepForTimeInterval:0.5]; - expect(testSuccess).toEventually(beTruthy()); - expect(testError).toEventually(beNil()); + expect(testSuccess).withTimeout(3.0).toEventually(beTrue()); + expect(testError).withTimeout(3.0).toEventually(beNil()); }); }); @@ -120,11 +119,10 @@ [resultResponses addObject:response]; } completionHandler:^(BOOL success) { expect(resultResponses).to(haveCount(3)); - expect(success).to(beFalsy()); + expect(success).to(beFalse()); }]; [testOperationQueue addOperation:testOperation]; - [NSThread sleepForTimeInterval:0.5]; }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m index 01eca9a7a..3c2bcc6dd 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLAudioStreamManagerSpec.m @@ -39,7 +39,6 @@ beforeEach(^{ [mockAudioManager clearData]; [testManager playNextWhenReady]; - // playNextWhenReady dispatches to a new thread so the test can sometimes fail due to timing issues even when using `toEventually`. }); it(@"should fail to send data", ^{ @@ -88,13 +87,7 @@ it(@"should be sending data", ^{ expect(testManager.isPlaying).toEventually(beTrue()); expect(mockAudioManager.dataSinceClear.length).toEventually(equal(34380)); - - // wait for the delegate to be called when the audio finishes - float waitTime = 1.1 + 0.25; // length of audio in testAudioFileURL + 0.25 buffer - NSLog(@"Please wait %f for audio file to finish playing...", waitTime); - [NSThread sleepForTimeInterval:waitTime]; - - expect(mockAudioManager.finishedPlaying).toEventually(beTrue()); + expect(mockAudioManager.finishedPlaying).withTimeout(3.0).toEventually(beTrue()); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m index f7ea93fc8..b8ab4f206 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m @@ -121,14 +121,12 @@ @implementation FileManagerSpecHelper startupError = error; completionHandlerCalled = YES; }]; - - [NSThread sleepForTimeInterval:0.1]; }); it(@"should have queued a ListFiles request", ^{ - expect(testFileManager.currentState).to(match(SDLFileManagerStateFetchingInitialList)); - expect(testFileManager.pendingTransactions).to(haveCount(@1)); - expect(testFileManager.pendingTransactions.firstObject).to(beAnInstanceOf([SDLListFilesOperation class])); + expect(testFileManager.currentState).toEventually(match(SDLFileManagerStateFetchingInitialList)); + expect(testFileManager.pendingTransactions).toEventually(haveCount(@1)); + expect(testFileManager.pendingTransactions.firstObject).toEventually(beAnInstanceOf([SDLListFilesOperation class])); }); describe(@"after going to the shutdown state and receiving a ListFiles response", ^{ diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m index 4d7f71d93..62b2df129 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m @@ -295,11 +295,10 @@ + (void)configure:(Configuration *)configuration { beforeEach(^{ [testManager.notificationDispatcher postNotificationName:SDLRPCServiceDidConnect infoObject:nil]; [testManager.notificationDispatcher postNotificationName:SDLTransportDidDisconnect infoObject:nil]; - [NSThread sleepForTimeInterval:0.1]; }); it(@"should be in the started state", ^{ - expect(testManager.lifecycleState).to(equal(SDLLifecycleStateReconnecting)); + expect(testManager.lifecycleState).toEventually(equal(SDLLifecycleStateReconnecting)); }); }); @@ -491,11 +490,10 @@ + (void)configure:(Configuration *)configuration { OCMStub([protocolMock stopWithCompletionHandler:[OCMArg invokeBlock]]); OCMStub([secondaryTransportManagerMock stopWithCompletionHandler:[OCMArg invokeBlock]]); [testManager.notificationDispatcher postNotificationName:SDLTransportDidDisconnect infoObject:nil]; - [NSThread sleepForTimeInterval:1.0]; }); it(@"should enter the started state", ^{ - expect(testManager.lifecycleState).toEventually(equal(SDLLifecycleStateStarted)); + expect(testManager.lifecycleState).withTimeout(3.0).toEventually(equal(SDLLifecycleStateStarted)); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLSequentialRPCRequestOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLSequentialRPCRequestOperationSpec.m index 9f3f5cc93..ab7001ae0 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLSequentialRPCRequestOperationSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLSequentialRPCRequestOperationSpec.m @@ -51,20 +51,19 @@ testOperation = [[SDLSequentialRPCRequestOperation alloc] initWithConnectionManager:testConnectionManager requests:sendRequests.copy progressHandler:^BOOL(__kindof SDLRPCRequest * _Nonnull request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error, float percentComplete) { TestRequestProgressResponse *progressResponse = testProgressResponses[request.correlationID]; - expect(progressResponse.percentComplete).toEventually(beCloseTo(percentComplete)); - expect(response).toEventuallyNot(beNil()); - expect(error).toEventually(beNil()); + expect(progressResponse.percentComplete).to(beCloseTo(percentComplete)); + expect(response).toNot(beNil()); + expect(error).to(beNil()); [resultResponses addObject:response]; return YES; } completionHandler:^(BOOL success) { expect(resultResponses).to(haveCount(3)); - expect(success).to(beTruthy()); + expect(success).to(beTrue()); }]; [testOperationQueue addOperation:testOperation]; - [NSThread sleepForTimeInterval:0.5]; }); }); @@ -82,11 +81,10 @@ return NO; } completionHandler:^(BOOL success) { expect(resultResponses).to(haveCount(1)); - expect(success).to(beFalsy()); + expect(success).to(beFalse()); }]; [testOperationQueue addOperation:testOperation]; - [NSThread sleepForTimeInterval:0.5]; }); }); }); @@ -124,11 +122,10 @@ return YES; } completionHandler:^(BOOL success) { expect(resultResponses).to(haveCount(3)); - expect(success).to(beFalsy()); + expect(success).to(beFalse()); }]; [testOperationQueue addOperation:testOperation]; - [NSThread sleepForTimeInterval:0.5]; }); }); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m index 8ddfd6aec..ffb8bf541 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m @@ -208,18 +208,17 @@ - (void)sdl_displayCapabilityDidUpdate; testObject2 = [[SDLSoftButtonObject alloc] initWithName:object2Name state:object2State1 handler:nil]; testManager.softButtonObjects = @[testObject1, testObject2]; - [NSThread sleepForTimeInterval:0.1]; }); it(@"should set soft buttons correctly", ^{ - 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)); + 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)); // One replace operation - expect(testManager.transactionQueue.operationCount).to(equal(1)); + expect(testManager.transactionQueue.operationCount).toEventually(equal(1)); }); it(@"should replace earlier operations when a replace operation is entered", ^{ diff --git a/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m b/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m index 952efd471..1ae8c65fd 100644 --- a/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m +++ b/SmartDeviceLinkTests/SDLAsynchronousRPCOperationSpec.m @@ -40,9 +40,7 @@ it(@"should correctly send the rpc", ^{ testOperation = [[SDLAsynchronousRPCOperation alloc] initWithConnectionManager:testConnectionManager rpc:sendRPC]; - [testOperationQueue addOperation:testOperation]; - [NSThread sleepForTimeInterval:0.1]; expect(testConnectionManager.receivedRequests).toEventually(contain(sendRPC)); }); @@ -85,9 +83,7 @@ [testOperationQueue cancelAllOperations]; [testOperationQueue setSuspended:NO]; - [NSThread sleepForTimeInterval:0.5]; - - expect(testConnectionManager.receivedRequests).toEventually(beEmpty()); + expect(testConnectionManager.receivedRequests).withTimeout(3.0).toEventually(beEmpty()); }); }); }); diff --git a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m index 30c6dc23d..20995e746 100644 --- a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m +++ b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m @@ -607,8 +607,8 @@ @interface SDLSystemCapabilityManager () it(@"should should not save the capabilities", ^{ [testSystemCapabilityManager updateCapabilityType:SDLSystemCapabilityTypePhoneCall completionHandler:^(NSError * _Nullable error, SDLSystemCapabilityManager * _Nonnull systemCapabilityManager) { - expect(error).toEventually(equal(testConnectionManager.defaultError)); - expect(systemCapabilityManager.phoneCapability).toEventually(beNil()); + expect(error).to(equal(testConnectionManager.defaultError)); + expect(systemCapabilityManager.phoneCapability).to(beNil()); }]; [NSThread sleepForTimeInterval:0.1]; @@ -624,8 +624,8 @@ @interface SDLSystemCapabilityManager () it(@"should save the capabilitity", ^{ [testSystemCapabilityManager updateCapabilityType:SDLSystemCapabilityTypePhoneCall completionHandler:^(NSError * _Nullable error, SDLSystemCapabilityManager * _Nonnull systemCapabilityManager) { - expect(testSystemCapabilityManager.phoneCapability).toEventually(equal(testPhoneCapability)); - expect(error).toEventually(beNil()); + expect(testSystemCapabilityManager.phoneCapability).to(equal(testPhoneCapability)); + expect(error).to(beNil()); }]; [NSThread sleepForTimeInterval:0.1]; @@ -635,7 +635,7 @@ @interface SDLSystemCapabilityManager () }); afterEach(^{ - // Make sure the RAIR properties and other system capabilities were not inadverdently set + // Make sure the RAIR properties and other system capabilities were not inadvertently set expect(testSystemCapabilityManager.displays).to(beNil()); expect(testSystemCapabilityManager.hmiCapabilities).to(beNil()); #pragma clang diagnostic push From e047a2300bac89186a5b9cf0bed4711d4e9f6c7f Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 3 Mar 2021 13:20:40 -0500 Subject: [PATCH 03/13] Additional test stuff --- .../SDLSecondaryTransportManagerSpec.m | 20 +++---------------- .../SDLSystemCapabilityManagerSpec.m | 6 ++---- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m index 41db3cdad..e4a9d1d40 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m @@ -726,13 +726,9 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve OCMExpect([testStreamingProtocolDelegate transportClosed]); - // Wait for the timer to elapse - float waitTime = RegisterTransportTime; - NSLog(@"Please wait for register transport timer to elapse... (for %.02f seconds)", waitTime); - [NSThread sleepForTimeInterval:waitTime]; + [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)); }); @@ -743,12 +739,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [testSecondaryProtocolMock onTransportConnected]; - // Wait for the timer to elapse - float waitTime = RegisterTransportTime; - NSLog(@"Please wait for register transport timer to elapse... (for %.02f seconds)", waitTime); - [NSThread sleepForTimeInterval:waitTime]; - - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateReconnecting)); + expect(manager.stateMachine.currentState).withTimeout(3.0).toEventually(equal(SDLSecondaryTransportStateReconnecting)); }); }); }); @@ -1011,12 +1002,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [manager.stateMachine setToState:SDLSecondaryTransportStateReconnecting fromOldState:nil callEnterTransition:YES]; }); - // wait for the timer - float waitTime = RetryConnectionDelay; - NSLog(@"Please wait for reconnection timeout... (for %.02f seconds)", waitTime); - [NSThread sleepForTimeInterval:waitTime]; - - expect(manager.stateMachine.currentState).toEventually(equal(SDLSecondaryTransportStateConfigured)); + expect(manager.stateMachine.currentState).withTimeout(10.0).toEventually(equal(SDLSecondaryTransportStateConfigured)); }); }); diff --git a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m index 20995e746..065b908e3 100644 --- a/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m +++ b/SmartDeviceLinkTests/SDLSystemCapabilityManagerSpec.m @@ -611,8 +611,7 @@ @interface SDLSystemCapabilityManager () expect(systemCapabilityManager.phoneCapability).to(beNil()); }]; - [NSThread sleepForTimeInterval:0.1]; - + [NSThread sleepForTimeInterval:0.1]; // This still needs to be here to ensure request is sent first [testConnectionManager respondToLastRequestWithResponse:testGetSystemCapabilityResponse]; }); }); @@ -628,8 +627,7 @@ @interface SDLSystemCapabilityManager () expect(error).to(beNil()); }]; - [NSThread sleepForTimeInterval:0.1]; - + [NSThread sleepForTimeInterval:0.1]; // This still needs to be here to ensure request is sent first [testConnectionManager respondToLastRequestWithResponse:testGetSystemCapabilityResponse]; }); }); From 65d6787693833395a425da02f28cfc5fde110127 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 3 Mar 2021 13:37:07 -0500 Subject: [PATCH 04/13] Comment out unused test constant --- .../ProxySpecs/SDLSecondaryTransportManagerSpec.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m index e4a9d1d40..d028b8624 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m @@ -44,7 +44,7 @@ typedef NS_ENUM(NSInteger, SDLSecondaryTransportType) { }; // should be in sync with SDLSecondaryTransportManager.m -static const float RetryConnectionDelay = 5.25; +//static const float RetryConnectionDelay = 5.25; static const float RegisterTransportTime = 10.25; static const int TCPPortUnspecified = -1; From 6955cedb33c4c9ef17cb77277bace7663522083f Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 3 Mar 2021 13:54:33 -0500 Subject: [PATCH 05/13] Add a sleep --- SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m index 7271889d5..1ad1e246e 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m @@ -146,6 +146,8 @@ @interface SDLVoiceCommandManager() SDLVoiceCommandUpdateOperation *firstOp = testManager.transactionQueue.operations[0]; firstOp.currentVoiceCommands = [@[testVoiceCommand2] mutableCopy]; [firstOp finishOperation]; + + [NSThread sleepForTimeInterval:0.5]; }); it(@"should update the second operation", ^{ From c0cec6632d7233d3b9e3b77c3b6d7dd1851b9182 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 3 Mar 2021 14:52:38 -0500 Subject: [PATCH 06/13] Potential fix to failing test --- SmartDeviceLinkTests/SDLAlertManagerSpec.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SmartDeviceLinkTests/SDLAlertManagerSpec.m b/SmartDeviceLinkTests/SDLAlertManagerSpec.m index e39d770cc..c84b82456 100644 --- a/SmartDeviceLinkTests/SDLAlertManagerSpec.m +++ b/SmartDeviceLinkTests/SDLAlertManagerSpec.m @@ -186,8 +186,8 @@ @interface SDLPresentAlertOperation() SDLPresentAlertOperation *presentAlertOp2 = testAlertManager.transactionQueue.operations[1]; expect(presentAlertOp1.isExecuting).to(beTrue()); expect(presentAlertOp2.isExecuting).to(beFalse()); - expect(presentAlertOp2.currentWindowCapability).to(equal(testWindowCapability)); - expect(presentAlertOp1.currentWindowCapability).to(equal(testWindowCapability)); + expect(presentAlertOp2.currentWindowCapability).toEventually(equal(testWindowCapability)); + expect(presentAlertOp1.currentWindowCapability).toEventually(equal(testWindowCapability)); }); }); From f756e87140cd34061c4a54db239e05c307981890 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 3 Mar 2021 15:09:51 -0500 Subject: [PATCH 07/13] Attempt to fix CI failures --- .../DevAPISpecs/SDLSoftButtonManagerSpec.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m index ffb8bf541..1c29aacf8 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m @@ -224,10 +224,10 @@ - (void)sdl_displayCapabilityDidUpdate; it(@"should replace earlier operations when a replace operation is entered", ^{ [testObject1 transitionToNextState]; testManager.softButtonObjects = @[testObject1]; - 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()); + expect(testManager.transactionQueue.operationCount).toEventually(equal(3)); + expect(testManager.transactionQueue.operations[0].isCancelled).toEventually(beTrue()); + expect(testManager.transactionQueue.operations[1].isCancelled).toEventually(beTrue()); + expect(testManager.transactionQueue.operations[2].isCancelled).toEventually(beFalse()); }); it(@"should retrieve soft buttons correctly", ^{ From 1ec370117ec805bc838aee5b0e2a9300c3ece1a8 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 3 Mar 2021 16:00:30 -0500 Subject: [PATCH 08/13] Attempt a fix --- .../DevAPISpecs/SDLSoftButtonManagerSpec.m | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m index 1c29aacf8..b1822ed9c 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m @@ -195,6 +195,7 @@ - (void)sdl_displayCapabilityDidUpdate; }); }); + // valid button objects (button objects have different names) describe(@"valid button objects (button objects have different names)", ^{ beforeEach(^{ SDLOnHMIStatus *status = [[SDLOnHMIStatus alloc] init]; @@ -210,6 +211,7 @@ - (void)sdl_displayCapabilityDidUpdate; testManager.softButtonObjects = @[testObject1, testObject2]; }); + // should set soft buttons correctly it(@"should set soft buttons correctly", ^{ expect(testManager.softButtonObjects).toEventuallyNot(beNil()); expect(testObject1.buttonId).toEventually(equal(1)); @@ -221,13 +223,16 @@ - (void)sdl_displayCapabilityDidUpdate; expect(testManager.transactionQueue.operationCount).toEventually(equal(1)); }); + // should replace earlier operations when a replace operation is entered it(@"should replace earlier operations when a replace operation is entered", ^{ [testObject1 transitionToNextState]; testManager.softButtonObjects = @[testObject1]; - expect(testManager.transactionQueue.operationCount).toEventually(equal(3)); - expect(testManager.transactionQueue.operations[0].isCancelled).toEventually(beTrue()); - expect(testManager.transactionQueue.operations[1].isCancelled).toEventually(beTrue()); - expect(testManager.transactionQueue.operations[2].isCancelled).toEventually(beFalse()); + [NSThread sleepForTimeInterval:0.5]; // Necessary to not get range exceptions with toEventually? + + 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", ^{ From d810863db37e4844aec65ae8f408d08937beee88 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Thu, 4 Mar 2021 08:35:21 -0500 Subject: [PATCH 09/13] Another attempt --- SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m index 1ad1e246e..3fed04f1c 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLVoiceCommandManagerSpec.m @@ -151,9 +151,7 @@ @interface SDLVoiceCommandManager() }); it(@"should update the second operation", ^{ - SDLVoiceCommandUpdateOperation *secondOp = testManager.transactionQueue.operations[0]; - - expect(secondOp.oldVoiceCommands.firstObject).withTimeout(3.0).toEventually(equal(testVoiceCommand2)); + expect(((SDLVoiceCommandUpdateOperation *)testManager.transactionQueue.operations.firstObject).oldVoiceCommands.firstObject).withTimeout(3.0).toEventually(equal(testVoiceCommand2)); }); }); }); From 1531a2ad7071b0a60a8585c327b4140165695bfe Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Fri, 5 Mar 2021 11:09:22 -0500 Subject: [PATCH 10/13] Fix commented line --- .../ProxySpecs/SDLSecondaryTransportManagerSpec.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m index d028b8624..0fab69340 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m @@ -44,7 +44,7 @@ typedef NS_ENUM(NSInteger, SDLSecondaryTransportType) { }; // should be in sync with SDLSecondaryTransportManager.m -//static const float RetryConnectionDelay = 5.25; +static const float RetryConnectionDelay = 5.25; static const float RegisterTransportTime = 10.25; static const int TCPPortUnspecified = -1; @@ -1002,7 +1002,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [manager.stateMachine setToState:SDLSecondaryTransportStateReconnecting fromOldState:nil callEnterTransition:YES]; }); - expect(manager.stateMachine.currentState).withTimeout(10.0).toEventually(equal(SDLSecondaryTransportStateConfigured)); + expect(manager.stateMachine.currentState).withTimeout(RegisterTransportTime + 3.0).toEventually(equal(SDLSecondaryTransportStateConfigured)); }); }); From 2522d88b35338f9eb42c7462161680e99fb6bf37 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Fri, 5 Mar 2021 15:28:03 -0500 Subject: [PATCH 11/13] Fix using the wrong constant --- .../ProxySpecs/SDLSecondaryTransportManagerSpec.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m index 0fab69340..9b424cc27 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLSecondaryTransportManagerSpec.m @@ -1002,7 +1002,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve [manager.stateMachine setToState:SDLSecondaryTransportStateReconnecting fromOldState:nil callEnterTransition:YES]; }); - expect(manager.stateMachine.currentState).withTimeout(RegisterTransportTime + 3.0).toEventually(equal(SDLSecondaryTransportStateConfigured)); + expect(manager.stateMachine.currentState).withTimeout(RetryConnectionDelay + 3.0).toEventually(equal(SDLSecondaryTransportStateConfigured)); }); }); From 5e5abd82a0b5ec2c87e88fcc667d45cf7c614aea Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Tue, 9 Mar 2021 15:29:24 -0500 Subject: [PATCH 12/13] Add more eventuallys --- .../DevAPISpecs/SDLSoftButtonManagerSpec.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m index b1822ed9c..437789ee0 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m @@ -229,10 +229,10 @@ - (void)sdl_displayCapabilityDidUpdate; testManager.softButtonObjects = @[testObject1]; [NSThread sleepForTimeInterval:0.5]; // Necessary to not get range exceptions with toEventually? - 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()); + 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()); }); it(@"should retrieve soft buttons correctly", ^{ From 49766aeb87f331e187320aee3d08a39d9d8dda89 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Tue, 9 Mar 2021 15:45:06 -0500 Subject: [PATCH 13/13] More fix attempts --- SmartDeviceLinkTests/SDLAlertManagerSpec.m | 4 ++-- SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SmartDeviceLinkTests/SDLAlertManagerSpec.m b/SmartDeviceLinkTests/SDLAlertManagerSpec.m index c84b82456..a4df0e7f2 100644 --- a/SmartDeviceLinkTests/SDLAlertManagerSpec.m +++ b/SmartDeviceLinkTests/SDLAlertManagerSpec.m @@ -158,8 +158,8 @@ @interface SDLPresentAlertOperation() SDLPresentAlertOperation *presentAlertOp2 = testAlertManager.transactionQueue.operations[1]; expect(presentAlertOp1.isExecuting).to(beTrue()); expect(presentAlertOp2.isExecuting).to(beFalse()); - expect(presentAlertOp1.currentWindowCapability).to(equal(testWindowCapability)); - expect(presentAlertOp2.currentWindowCapability).to(beNil()); + expect(presentAlertOp1.currentWindowCapability).toEventually(equal(testWindowCapability)); + expect(presentAlertOp2.currentWindowCapability).toEventually(beNil()); }); it(@"should start the queue if the new capability is not nil and update the pending operations with the new capability", ^{ diff --git a/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m b/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m index e9395e86c..599afa415 100644 --- a/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m +++ b/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m @@ -697,8 +697,8 @@ - (SDLAlert *)alertRPC; [testPresentAlertOperation start]; - expect(testPresentAlertOperation.internalError).to(equal([NSError sdl_alertManager_alertDataInvalid])); - expect(hasCalledOperationCompletionHandler).to(beTrue()); + expect(testPresentAlertOperation.internalError).toEventually(equal([NSError sdl_alertManager_alertDataInvalid])); + expect(hasCalledOperationCompletionHandler).toEventually(beTrue()); expect(testPresentAlertOperation.isFinished).toEventually(beTrue()); }); });