From 56f883b96918d29a7bb2eacddf3c8b7dbb723451 Mon Sep 17 00:00:00 2001 From: NicoleYarroch Date: Fri, 2 Oct 2020 13:19:05 -0400 Subject: Fixed crash Removed unused helper test cases Signed-off-by: NicoleYarroch --- SmartDeviceLink-iOS.xcodeproj/project.pbxproj | 20 ------ .../DevAPISpecs/SDLLifecycleManagerSpec.m | 72 ++++++++++------------ .../TestOldConfigurationUpdateManagerDelegate.h | 19 ------ .../TestOldConfigurationUpdateManagerDelegate.m | 24 -------- .../TestNewConfigurationUpdateManagerDelegate.h | 19 ------ .../TestNewConfigurationUpdateManagerDelegate.m | 21 ------- 6 files changed, 34 insertions(+), 141 deletions(-) delete mode 100644 SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h delete mode 100644 SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m delete mode 100644 SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.h delete mode 100644 SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.m diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index b2ddf4dbf..181f2f387 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -300,8 +300,6 @@ 4A457DD524A3C16E00386CBA /* SDLLifecycleMobileHMIStateHandlerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A457DD424A3C16E00386CBA /* SDLLifecycleMobileHMIStateHandlerSpec.m */; }; 4A457DD724A3CCED00386CBA /* SDLLifecycleSystemRequestHandlerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A457DD624A3CCED00386CBA /* SDLLifecycleSystemRequestHandlerSpec.m */; }; 4A457DD924A5137100386CBA /* SDLLifecycleProtocolHandlerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A457DD824A5137100386CBA /* SDLLifecycleProtocolHandlerSpec.m */; }; - 4A4AD8A424894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A4AD8A324894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m */; }; - 4A4AD8A724894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A4AD8A624894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m */; }; 4A877499251BBE2400A8BEBB /* SmartDeviceLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A877498251BBE2400A8BEBB /* SmartDeviceLink.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4A8BD23B24F93135000945E3 /* SDLMassageCushionFirmness.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A8BD22324F93131000945E3 /* SDLMassageCushionFirmness.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4A8BD23C24F93135000945E3 /* SDLMediaServiceData.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A8BD22424F93131000945E3 /* SDLMediaServiceData.m */; }; @@ -2080,10 +2078,6 @@ 4A457DD424A3C16E00386CBA /* SDLLifecycleMobileHMIStateHandlerSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDLLifecycleMobileHMIStateHandlerSpec.m; path = DevAPISpecs/SDLLifecycleMobileHMIStateHandlerSpec.m; sourceTree = ""; }; 4A457DD624A3CCED00386CBA /* SDLLifecycleSystemRequestHandlerSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDLLifecycleSystemRequestHandlerSpec.m; path = DevAPISpecs/SDLLifecycleSystemRequestHandlerSpec.m; sourceTree = ""; }; 4A457DD824A5137100386CBA /* SDLLifecycleProtocolHandlerSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDLLifecycleProtocolHandlerSpec.m; path = DevAPISpecs/SDLLifecycleProtocolHandlerSpec.m; sourceTree = ""; }; - 4A4AD8A224894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TestOldConfigurationUpdateManagerDelegate.h; path = DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h; sourceTree = ""; }; - 4A4AD8A324894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = TestOldConfigurationUpdateManagerDelegate.m; path = DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m; sourceTree = ""; }; - 4A4AD8A524894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestNewConfigurationUpdateManagerDelegate.h; sourceTree = ""; }; - 4A4AD8A624894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestNewConfigurationUpdateManagerDelegate.m; sourceTree = ""; }; 4A6B0D6125262D130025516A /* EAAccessory+OCMock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "EAAccessory+OCMock.h"; sourceTree = ""; }; 4A877498251BBE2400A8BEBB /* SmartDeviceLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmartDeviceLink.h; path = public/SmartDeviceLink.h; sourceTree = ""; }; 4A8BD22324F93131000945E3 /* SDLMassageCushionFirmness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDLMassageCushionFirmness.h; path = public/SDLMassageCushionFirmness.h; sourceTree = ""; }; @@ -4190,17 +4184,6 @@ name = "Update Operation"; sourceTree = ""; }; - 4A4AD8A12489422F008FC414 /* Utilities */ = { - isa = PBXGroup; - children = ( - 4A4AD8A224894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.h */, - 4A4AD8A324894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m */, - 4A4AD8A524894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.h */, - 4A4AD8A624894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m */, - ); - name = Utilities; - sourceTree = ""; - }; 4A6B0D6025262CF50025516A /* Utilities */ = { isa = PBXGroup; children = ( @@ -4334,7 +4317,6 @@ 5D1654541D3E753100554D93 /* Lifecycle */ = { isa = PBXGroup; children = ( - 4A4AD8A12489422F008FC414 /* Utilities */, 5D1654551D3E754F00554D93 /* SDLLifecycleManagerSpec.m */, 888F86FF221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m */, 5D60DF23202B7A80001EDA01 /* SDLAsynchronousRPCRequestOperationSpec.m */, @@ -8268,7 +8250,6 @@ 1EAA47722036AEF5000FE74B /* SDLLightNameSpec.m in Sources */, 5DB92D2F1AC59F0000C15BB0 /* SDLObjectWithPrioritySpec.m in Sources */, 88DF999122035D5A00477AC1 /* SDLIAPTransportSpec.m in Sources */, - 4A4AD8A424894260008FC414 /* TestOldConfigurationUpdateManagerDelegate.m in Sources */, 162E838A1A9BDE8B00906325 /* SDLSingleTireStatusSpec.m in Sources */, 5D6EB4CC1BF28DC600693731 /* NSMapTable+SubscriptingSpec.m in Sources */, B3F7918324E062C200DB5CAF /* SDLGetVehicleDataSpec.m in Sources */, @@ -8562,7 +8543,6 @@ 162E838F1A9BDE8B00906325 /* SDLTextFieldSpec.m in Sources */, 8818ADDD2100FE0C007D6F19 /* SDLTurnSignalSpec.m in Sources */, 162E82CA1A9BDE8A00906325 /* SDLAmbientLightStatusSpec.m in Sources */, - 4A4AD8A724894270008FC414 /* TestNewConfigurationUpdateManagerDelegate.m in Sources */, 162E83091A9BDE8B00906325 /* SDLVehicleDataStatusSpec.m in Sources */, 5DAD5F8D20508F220025624C /* SDLSoftButtonManagerSpec.m in Sources */, 162E83741A9BDE8B00906325 /* SDLBodyInformationSpec.m in Sources */, diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m index e07e0c6af..835080c34 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m @@ -46,13 +46,6 @@ #import "SDLVersion.h" #import "SDLVideoStreamingState.h" -#import "TestOldConfigurationUpdateManagerDelegate.h" -#import "TestNewConfigurationUpdateManagerDelegate.h" - - -// Ignore the deprecated proxy methods -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" @interface SDLStreamingMediaManager () @@ -98,15 +91,15 @@ QuickSpecBegin(SDLLifecycleManagerSpec) describe(@"a lifecycle manager", ^{ __block SDLLifecycleManager *testManager = nil; __block SDLConfiguration *testConfig = nil; - - __block id protocolMock = OCMClassMock([SDLProtocol class]); - __block id lockScreenManagerMock = OCMClassMock([SDLLockScreenManager class]); - __block id fileManagerMock = OCMClassMock([SDLFileManager class]); - __block id permissionManagerMock = OCMClassMock([SDLPermissionManager class]); - __block id streamingManagerMock = OCMClassMock([SDLStreamingMediaManager class]); - __block id systemCapabilityMock = OCMClassMock([SDLSystemCapabilityManager class]); - __block id secondaryTransportManagerMock = OCMClassMock([SDLSecondaryTransportManager class]); - __block id encryptionManagerMock = OCMClassMock([SDLEncryptionLifecycleManager class]); + __block id protocolMock = nil; + __block id sdlManagerDelegateProtocolMock = nil; + __block id lockScreenManagerMock = nil; + __block id fileManagerMock = nil; + __block id permissionManagerMock = nil; + __block id streamingManagerMock = nil; + __block id systemCapabilityMock = nil; + __block id secondaryTransportManagerMock = nil; + __block id encryptionManagerMock = nil; void (^transitionToState)(SDLState *) = ^(SDLState *state) { dispatch_sync(testManager.lifecycleQueue, ^{ @@ -121,6 +114,16 @@ describe(@"a lifecycle manager", ^{ }; beforeEach(^{ + protocolMock = OCMClassMock([SDLProtocol class]); + sdlManagerDelegateProtocolMock = OCMProtocolMock(@protocol(SDLManagerDelegate)); + lockScreenManagerMock = OCMClassMock([SDLLockScreenManager class]); + fileManagerMock = OCMClassMock([SDLFileManager class]); + permissionManagerMock = OCMClassMock([SDLPermissionManager class]); + streamingManagerMock = OCMClassMock([SDLStreamingMediaManager class]); + systemCapabilityMock = OCMClassMock([SDLSystemCapabilityManager class]); + secondaryTransportManagerMock = OCMClassMock([SDLSecondaryTransportManager class]); + encryptionManagerMock = OCMClassMock([SDLEncryptionLifecycleManager class]); + SDLLifecycleConfiguration *testLifecycleConfig = [SDLLifecycleConfiguration defaultConfigurationWithAppName:@"Test App" fullAppId:@"TestFullAppID"]; testLifecycleConfig.shortAppName = @"Short Name"; testLifecycleConfig.appType = SDLAppHMITypeNavigation; @@ -130,7 +133,7 @@ describe(@"a lifecycle manager", ^{ testConfig.lifecycleConfig.language = SDLLanguageEnUs; testConfig.lifecycleConfig.minimumProtocolVersion = [SDLVersion versionWithMajor:2 minor:0 patch:0]; testConfig.lifecycleConfig.minimumRPCVersion = [SDLVersion versionWithMajor:2 minor:0 patch:0]; - testManager = [[SDLLifecycleManager alloc] initWithConfiguration:testConfig delegate:OCMProtocolMock(@protocol(SDLManagerDelegate))]; + testManager = [[SDLLifecycleManager alloc] initWithConfiguration:testConfig delegate:sdlManagerDelegateProtocolMock]; testManager.lockScreenManager = lockScreenManagerMock; testManager.fileManager = fileManagerMock; testManager.permissionManager = permissionManagerMock; @@ -399,6 +402,12 @@ describe(@"a lifecycle manager", ^{ }); describe(@"transitioning to the ready state", ^{ + beforeEach(^{ + [testManager.lifecycleStateMachine setToState:SDLLifecycleStateRegistered fromOldState:nil callEnterTransition:NO]; + + expect(testManager.lifecycleState).to(equal(SDLLifecycleStateRegistered)); + }); + context(@"when the register response is a success", ^{ it(@"should call the ready handler with success", ^{ SDLRegisterAppInterfaceResponse *response = [[SDLRegisterAppInterfaceResponse alloc] init]; @@ -429,12 +438,6 @@ describe(@"a lifecycle manager", ^{ }); context(@"when the register response returns different language than the one passed with the lifecycle configuration", ^{ - __block TestNewConfigurationUpdateManagerDelegate *newDelegate = nil; - beforeEach(^{ - newDelegate = OCMClassMock([TestNewConfigurationUpdateManagerDelegate class]); - testManager.delegate = newDelegate; - }); - it(@"should should update the configuration when the app supports the head unit language", ^{ SDLRegisterAppInterfaceResponse *registerAppInterfaceResponse = [[SDLRegisterAppInterfaceResponse alloc] init]; registerAppInterfaceResponse.success = @YES; @@ -457,17 +460,14 @@ describe(@"a lifecycle manager", ^{ }]]); setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration); - // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine - [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO]; + + 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"])); - - OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]); - OCMVerifyAll(protocolMock); }); it(@"should not update the configuration when the app does not support the head unit language or display language", ^{ @@ -482,16 +482,14 @@ describe(@"a lifecycle manager", ^{ OCMStub([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]).andReturn(nil); setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration); - // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine - [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO]; + + 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()); - - OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]); }); it(@"should update when the app supports the head unit display language", ^{ @@ -506,6 +504,8 @@ describe(@"a lifecycle manager", ^{ SDLLifecycleConfigurationUpdate *update = [[SDLLifecycleConfigurationUpdate alloc] initWithAppName:@"EnGb" shortAppName:@"Gb" ttsName:nil voiceRecognitionCommandNames:nil]; OCMStub([testManager.delegate managerShouldUpdateLifecycleToLanguage:registerAppInterfaceResponse.language hmiLanguage:registerAppInterfaceResponse.hmiDisplayLanguage]).andReturn(update); + transitionToState(SDLLifecycleStateUpdatingConfiguration); + OCMExpect([protocolMock sendRPC:[OCMArg checkWithBlock:^BOOL(id value) { SDLChangeRegistration *changeRegistration = (SDLChangeRegistration *)value; expect(changeRegistration.appName).to(equal(update.appName)); @@ -516,16 +516,14 @@ describe(@"a lifecycle manager", ^{ }]]); setToStateWithEnterTransition(SDLLifecycleStateRegistered, SDLLifecycleStateUpdatingConfiguration); - // Transition to StateSettingUpManagers to prevent assert error from the lifecycle machine - [testManager.lifecycleStateMachine setToState:SDLLifecycleStateSettingUpManagers fromOldState:SDLLifecycleStateUpdatingConfiguration callEnterTransition:NO]; + + 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()); - - OCMVerify([testManager.delegate managerShouldUpdateLifecycleToLanguage:[OCMArg any] hmiLanguage:[OCMArg any]]); }); }); }); @@ -808,5 +806,3 @@ describe(@"a lifecycle manager", ^{ }); QuickSpecEnd - -#pragma clang diagnostic pop diff --git a/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h b/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h deleted file mode 100644 index f527decea..000000000 --- a/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// TestOldConfigurationUpdateManagerDelegate.h -// SmartDeviceLinkTests -// -// Created by Joel Fischer on 6/4/20. -// Copyright © 2020 smartdevicelink. All rights reserved. -// - -#import - -#import "SDLManagerDelegate.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface TestOldConfigurationUpdateManagerDelegate : NSObject - -@end - -NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m b/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m deleted file mode 100644 index 765df8172..000000000 --- a/SmartDeviceLinkTests/DevAPISpecs/TestOldConfigurationUpdateManagerDelegate.m +++ /dev/null @@ -1,24 +0,0 @@ -// -// TestOldConfigurationUpdateManagerDelegate.m -// SmartDeviceLinkTests -// -// Created by Joel Fischer on 6/4/20. -// Copyright © 2020 smartdevicelink. All rights reserved. -// - -#import "TestOldConfigurationUpdateManagerDelegate.h" - -@implementation TestOldConfigurationUpdateManagerDelegate - -- (void)hmiLevel:(nonnull SDLHMILevel)oldLevel didChangeToLevel:(nonnull SDLHMILevel)newLevel { } - -- (void)managerDidDisconnect { } - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -- (nullable SDLLifecycleConfigurationUpdate *)managerShouldUpdateLifecycleToLanguage:(SDLLanguage)language { - return nil; -} -#pragma mark diagnostic pop - -@end diff --git a/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.h b/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.h deleted file mode 100644 index 67e3c8948..000000000 --- a/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// TestNewConfigurationUpdateManagerDelegate.h -// SmartDeviceLinkTests -// -// Created by Joel Fischer on 6/4/20. -// Copyright © 2020 smartdevicelink. All rights reserved. -// - -#import - -#import "SDLManagerDelegate.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface TestNewConfigurationUpdateManagerDelegate : NSObject - -@end - -NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.m b/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.m deleted file mode 100644 index fee42d105..000000000 --- a/SmartDeviceLinkTests/TestNewConfigurationUpdateManagerDelegate.m +++ /dev/null @@ -1,21 +0,0 @@ -// -// TestNewConfigurationUpdateManagerDelegate.m -// SmartDeviceLinkTests -// -// Created by Joel Fischer on 6/4/20. -// Copyright © 2020 smartdevicelink. All rights reserved. -// - -#import "TestNewConfigurationUpdateManagerDelegate.h" - -@implementation TestNewConfigurationUpdateManagerDelegate - -- (void)hmiLevel:(nonnull SDLHMILevel)oldLevel didChangeToLevel:(nonnull SDLHMILevel)newLevel { } - -- (void)managerDidDisconnect { } - -- (nullable SDLLifecycleConfigurationUpdate *)managerShouldUpdateLifecycleToLanguage:(SDLLanguage)language hmiLanguage:(SDLLanguage)hmiLanguage { - return nil; -} - -@end -- cgit v1.2.1