diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2020-05-06 15:50:38 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2020-05-06 15:50:38 -0400 |
commit | a756ccf1dbf9b96d7ba83eba771994f1886181e0 (patch) | |
tree | 4d100da13f8ff3dadb5259908eeb8b95b4d5c1ee | |
parent | f7a2d9ee52063ea00799899950c95fa2778fd4cf (diff) | |
download | sdl_ios-bugfix/issue-1631-focusableitemlocator-stop.tar.gz |
Update unit testsbugfix/issue-1631-focusableitemlocator-stop
-rw-r--r-- | SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m index 77a658a86..c5e50301f 100644 --- a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m +++ b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m @@ -367,27 +367,64 @@ describe(@"the haptic manager", ^{ [hapticManager updateInterfaceLayout]; viewRect2 = CGRectMake(201, 201, 50, 50); - UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2]; + UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2]; [uiViewController.view addSubview:textField2]; + }); + + context(@"when not started", ^{ + beforeEach(^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidUpdateProjectionView object:nil]; + }); + + it(@"should have one view", ^{ + int expectedCount = 1; + expect(sentHapticRequest.hapticRectData.count).toEventually(equal(expectedCount)); - [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidUpdateProjectionView object:nil]; + if(sentHapticRequest.hapticRectData.count == expectedCount) { + NSArray<SDLHapticRect *> *hapticRectData = sentHapticRequest.hapticRectData; + SDLHapticRect *sdlhapticRect1 = hapticRectData[0]; + SDLRectangle *sdlRect1 = sdlhapticRect1.rect; + + compareRectangle(sdlRect1, viewRect1); + } + }); }); - it(@"should have two views", ^{ - int expectedCount = 2; - expect(sentHapticRequest.hapticRectData.count).toEventually(equal(expectedCount)); + context(@"when started", ^{ + beforeEach(^{ + [hapticManager start]; + [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidUpdateProjectionView object:nil]; + }); - if(sentHapticRequest.hapticRectData.count == expectedCount) { - NSArray<SDLHapticRect *> *hapticRectData = sentHapticRequest.hapticRectData; - SDLHapticRect *sdlhapticRect1 = hapticRectData[0]; - SDLRectangle *sdlRect1 = sdlhapticRect1.rect; + it(@"should have two views", ^{ + int expectedCount = 2; + expect(sentHapticRequest.hapticRectData.count).toEventually(equal(expectedCount)); - SDLHapticRect *sdlhapticRect2 = hapticRectData[1]; - SDLRectangle *sdlRect2 = sdlhapticRect2.rect; + if(sentHapticRequest.hapticRectData.count == expectedCount) { + NSArray<SDLHapticRect *> *hapticRectData = sentHapticRequest.hapticRectData; + SDLHapticRect *sdlhapticRect1 = hapticRectData[0]; + SDLRectangle *sdlRect1 = sdlhapticRect1.rect; - compareRectangle(sdlRect1, viewRect2); - compareRectangle(sdlRect2, viewRect1); - } + SDLHapticRect *sdlhapticRect2 = hapticRectData[1]; + SDLRectangle *sdlRect2 = sdlhapticRect2.rect; + + compareRectangle(sdlRect1, viewRect2); + compareRectangle(sdlRect2, viewRect1); + } + }); + + context(@"when stopped", ^{ + beforeEach(^{ + [hapticManager stop]; + for (UIView *subview in uiViewController.view.subviews) { [subview removeFromSuperview]; } + [[NSNotificationCenter defaultCenter] postNotificationName:SDLDidUpdateProjectionView object:nil]; + }); + + it(@"should have two views", ^{ + int expectedCount = 2; + expect(sentHapticRequest.hapticRectData.count).toEventually(equal(expectedCount)); + }); + }); }); }); |