summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-09-28 15:21:23 -0400
committerJoel Fischer <joeljfischer@gmail.com>2017-09-28 15:21:23 -0400
commit1a3fc0b3185f77cd11e2b9f93b0c7a31ca6f2ced (patch)
tree5434fc22c5c697d7b76d295f23a0474c060cba27
parentd34a92bd185b928a30401269621189b713220737 (diff)
downloadsdl_ios-1a3fc0b3185f77cd11e2b9f93b0c7a31ca6f2ced.tar.gz
Fixed existing tests
-rw-r--r--SmartDeviceLink/SDLStreamingMediaLifecycleManager.m5
-rw-r--r--SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m61
-rw-r--r--SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m40
3 files changed, 56 insertions, 50 deletions
diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m
index a3c46a9d4..e86ab2c0b 100644
--- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m
+++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m
@@ -107,6 +107,8 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
if (configuration.window != nil) {
_hapticInterface = [[SDLHapticManager alloc] initWithWindow:configuration.window connectionManager:_connectionManager];
}
+ // __weak typeof(_hapticInterface) weakHaptic = _hapticInterface;
+ _touchManager = [[SDLTouchManager alloc] initWithHitTester:_hapticInterface];
_videoEncoderSettings = configuration.customVideoEncoderSettings ?: SDLH264VideoEncoder.defaultVideoEncoderSettings;
_requestedEncryptionType = configuration.maximumDesiredEncryption;
@@ -116,9 +118,6 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
_preferredFormatIndex = 0;
_preferredResolutionIndex = 0;
-// __weak typeof(_hapticInterface) weakHaptic = _hapticInterface;
- _touchManager = [[SDLTouchManager alloc] initWithHitTester:_hapticInterface];
-
SDLAppState *initialState = SDLAppStateInactive;
switch ([[UIApplication sharedApplication] applicationState]) {
case UIApplicationStateActive: {
diff --git a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m
index 527fe8e44..28bc1d4c9 100644
--- a/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m
+++ b/SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m
@@ -18,21 +18,6 @@
#import "SDLRectangle.h"
#import "SDLLifecycleManager.h"
-SDLTouch* generateTouchEvent(int xCoord, int yCoord)
-{
- unsigned long timeStamp = 10;
- SDLTouchCoord* firstCoord = [[SDLTouchCoord alloc] init];
- firstCoord.x = @(xCoord);
- firstCoord.y = @(yCoord);
-
- SDLTouchEvent* firstTouchEvent = [[SDLTouchEvent alloc] init];
- firstTouchEvent.touchEventId = @0;
- firstTouchEvent.coord = [NSArray arrayWithObject:firstCoord];
- firstTouchEvent.timeStamp = [NSMutableArray arrayWithObject:@(timeStamp)];
- SDLTouch* firstTouch = [[SDLTouch alloc] initWithTouchEvent:firstTouchEvent];
- return firstTouch;
-}
-
BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect)
{
expect(sdlRectangle.x).to(equal(cgRect.origin.x));
@@ -64,14 +49,31 @@ describe(@"the haptic manager", ^{
[uiWindow addSubview:uiViewController.view];
- OCMExpect( [[sdlLifecycleManager stub] sendManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
+ OCMExpect([[sdlLifecycleManager stub] sendManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);
+ });
+
+ context(@"when disabled", ^{
+ beforeEach(^{
+ viewRect1 = CGRectMake(101, 101, 50, 50);
+ UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
+ [uiWindow insertSubview:textField1 aboveSubview:uiWindow];
+
+ hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = NO;
+ [hapticManager updateInterfaceLayout];
+ });
+ it(@"should have no views", ^{
+ OCMVerify(sdlLifecycleManager);
+
+ expect(sentHapticRequest).to(beNil());
+ });
});
context(@"when initialized with no focusable view", ^{
@@ -93,6 +95,7 @@ describe(@"the haptic manager", ^{
[uiWindow insertSubview:textField1 aboveSubview:uiWindow];
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -119,6 +122,7 @@ describe(@"the haptic manager", ^{
[uiWindow addSubview:button];
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -141,6 +145,7 @@ describe(@"the haptic manager", ^{
context(@"when initialized with no views and then updated with two additional views", ^{
beforeEach(^{
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
viewRect1 = CGRectMake(101, 101, 50, 50);
@@ -188,6 +193,7 @@ describe(@"the haptic manager", ^{
[textField addSubview:textField2];
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -225,6 +231,7 @@ describe(@"the haptic manager", ^{
[button addSubview:textField2];
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
@@ -259,6 +266,7 @@ describe(@"the haptic manager", ^{
[uiViewController.view addSubview:textField2];
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
[textField2 removeFromSuperview];
@@ -289,6 +297,7 @@ describe(@"the haptic manager", ^{
[uiViewController.view addSubview:textField1];
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
viewRect2 = CGRectMake(201, 201, 50, 50);
@@ -327,18 +336,15 @@ describe(@"the haptic manager", ^{
[uiViewController.view addSubview:textField2];
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
it(@"should return a view object", ^{
- SDLTouch* collisionTouch1 = generateTouchEvent(125, 120);
- UIView* view1 = [hapticManager viewForSDLTouch:collisionTouch1];
-
+ UIView *view1 = [hapticManager viewForPoint:CGPointMake(125, 120)];
expect(view1).toNot(beNil());
-
- SDLTouch* collisionTouch2 = generateTouchEvent(202, 249);
- UIView* view2 = [hapticManager viewForSDLTouch:collisionTouch2];
-
+
+ UIView* view2 = [hapticManager viewForPoint:CGPointMake(202, 249)];
expect(view2).toNot(beNil());
});
});
@@ -352,13 +358,12 @@ describe(@"the haptic manager", ^{
[uiViewController.view addSubview:textField2];
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
it(@"should return no view object", ^{
- SDLTouch* collisionTouch = generateTouchEvent(130, 130);
- UIView* view = [hapticManager viewForSDLTouch:collisionTouch];
-
+ UIView* view = [hapticManager viewForPoint:CGPointMake(130, 130)];
expect(view).to(beNil());
});
});
@@ -369,11 +374,11 @@ describe(@"the haptic manager", ^{
[uiWindow insertSubview:textField1 aboveSubview:uiWindow];
hapticManager = [[SDLHapticManager alloc] initWithWindow:uiWindow connectionManager:sdlLifecycleManager];
+ hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
it(@"should return nil", ^{
- SDLTouch* collisionTouch = generateTouchEvent(0, 228);
- UIView* view = [hapticManager viewForSDLTouch:collisionTouch];
+ UIView* view = [hapticManager viewForPoint:CGPointMake(0, 228)];
expect(view).to(beNil());
});
diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m
index 801afabbb..a36c213ae 100644
--- a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m
+++ b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m
@@ -13,12 +13,14 @@
#import <OCMock/OCMock.h>
#import "SDLNotificationConstants.h"
+#import "SDLHapticManager.h"
#import "SDLOnTouchEvent.h"
#import "SDLPinchGesture.h"
#import "SDLRPCNotificationNotification.h"
#import "SDLTouchCoord.h"
#import "SDLTouchEvent.h"
#import "SDLTouchManager.h"
+#import "SDLTouchManagerDelegate.h"
#import "SDLTouchType.h"
#import "SDLTouch.h"
@@ -34,11 +36,11 @@
QuickSpecBegin(SDLTouchManagerSpec)
describe(@"SDLTouchManager Tests", ^{
- __block SDLTouchManager* touchManager;
+ __block SDLTouchManager *touchManager;
context(@"initializing", ^{
it(@"should correctly have default properties", ^{
- SDLTouchManager* touchManager = [[SDLTouchManager alloc] init];
+ SDLTouchManager* touchManager = [[SDLTouchManager alloc] initWithHitTester:nil];
expect(touchManager.touchEventDelegate).to(beNil());
expect(@(touchManager.tapDistanceThreshold)).to(equal(@50));
expect(@(touchManager.tapTimeThreshold)).to(beCloseTo(@0.4).within(0.0001));
@@ -96,7 +98,7 @@ describe(@"SDLTouchManager Tests", ^{
};
beforeEach(^{
- touchManager = [[SDLTouchManager alloc] init];
+ touchManager = [[SDLTouchManager alloc] initWithHitTester:nil];
delegateMock = OCMProtocolMock(@protocol(SDLTouchManagerDelegate));
touchManager.touchEventDelegate = delegateMock;
touchManager.touchEventHandler = ^(SDLTouch *touch, SDLTouchType type) {
@@ -110,7 +112,7 @@ describe(@"SDLTouchManager Tests", ^{
[[[[delegateMock stub] andDo:^(NSInvocation* invocation) {
didCallSingleTap = YES;
singleTapTests(invocation);
- }] ignoringNonObjectArgs] touchManager:[OCMArg any] didReceiveSingleTapAtPoint:CGPointZero];
+ }] ignoringNonObjectArgs] touchManager:[OCMArg any] didReceiveSingleTapForView:[OCMArg any] atPoint:CGPointZero];
singleTapTests = ^(NSInvocation* invocation) {
failWithMessage(@"Failed to call Single Tap Tests.");
};
@@ -119,7 +121,7 @@ describe(@"SDLTouchManager Tests", ^{
[[[[delegateMock stub] andDo:^(NSInvocation* invocation) {
didCallDoubleTap = YES;
doubleTapTests(invocation);
- }] ignoringNonObjectArgs] touchManager:[OCMArg any] didReceiveDoubleTapAtPoint:CGPointZero];
+ }] ignoringNonObjectArgs] touchManager:[OCMArg any] didReceiveDoubleTapForView:[OCMArg any] atPoint:CGPointZero];
doubleTapTests = ^(NSInvocation* invocation) {
failWithMessage(@"Failed to call Double Tap Tests.");
};
@@ -128,7 +130,7 @@ describe(@"SDLTouchManager Tests", ^{
[[[[delegateMock stub] andDo:^(NSInvocation* invocation) {
didCallBeginPan = YES;
panStartTests(invocation);
- }] ignoringNonObjectArgs] touchManager:[OCMArg any] panningDidStartAtPoint:CGPointZero];
+ }] ignoringNonObjectArgs] touchManager:[OCMArg any] panningDidStartInView:[OCMArg any] atPoint:CGPointZero];
panStartTests = ^(NSInvocation* invocation) {
failWithMessage(@"Failed to call Pan Start Tests.");
};
@@ -146,7 +148,7 @@ describe(@"SDLTouchManager Tests", ^{
[[[[delegateMock stub] andDo:^(NSInvocation* invocation) {
didCallEndPan = YES;
panEndTests(invocation);
- }] ignoringNonObjectArgs] touchManager:[OCMArg any] panningDidEndAtPoint:CGPointZero];
+ }] ignoringNonObjectArgs] touchManager:[OCMArg any] panningDidEndInView:[OCMArg any] atPoint:CGPointZero];
panEndTests = ^(NSInvocation* invocation) {
failWithMessage(@"Failed to call Pan End Tests.");
};
@@ -164,7 +166,7 @@ describe(@"SDLTouchManager Tests", ^{
[[[[delegateMock stub] andDo:^(NSInvocation* invocation) {
didCallBeginPinch = YES;
pinchStartTests(invocation);
- }] ignoringNonObjectArgs] touchManager:[OCMArg any] pinchDidStartAtCenterPoint:CGPointZero];
+ }] ignoringNonObjectArgs] touchManager:[OCMArg any] pinchDidStartInView:[OCMArg any] atCenterPoint:CGPointZero];
pinchStartTests = ^(NSInvocation* invocation) {
failWithMessage(@"Failed to call Pinch Start Tests.");
};
@@ -182,7 +184,7 @@ describe(@"SDLTouchManager Tests", ^{
[[[[delegateMock stub] andDo:^(NSInvocation* invocation) {
didCallEndPinch = YES;
pinchEndTests(invocation);
- }] ignoringNonObjectArgs] touchManager:[OCMArg any] pinchDidEndAtCenterPoint:CGPointZero];
+ }] ignoringNonObjectArgs] touchManager:[OCMArg any] pinchDidEndInView:[OCMArg any] atCenterPoint:CGPointZero];
pinchEndTests = ^(NSInvocation* invocation) {
failWithMessage(@"Failed to call Pinch End Tests.");
};
@@ -243,7 +245,7 @@ describe(@"SDLTouchManager Tests", ^{
__unsafe_unretained SDLTouchManager* touchManagerCallback;
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, controlPoint))).to(beTruthy());
@@ -295,7 +297,7 @@ describe(@"SDLTouchManager Tests", ^{
__unsafe_unretained SDLTouchManager* touchManagerCallback;
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, averagePoint))).to(beTruthy());
@@ -520,7 +522,7 @@ describe(@"SDLTouchManager Tests", ^{
__unsafe_unretained SDLTouchManager* touchManagerCallback;
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, panMovePoint))).to(beTruthy());
@@ -543,7 +545,7 @@ describe(@"SDLTouchManager Tests", ^{
__unsafe_unretained SDLTouchManager* touchManagerCallback;
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, panEndPoint))).to(beTruthy());
@@ -568,7 +570,7 @@ describe(@"SDLTouchManager Tests", ^{
__unsafe_unretained SDLTouchManager* touchManagerCallback;
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, panMovePoint))).to(beTruthy());
@@ -600,7 +602,7 @@ describe(@"SDLTouchManager Tests", ^{
__unsafe_unretained SDLTouchManager* touchManagerCallback;
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, panMovePoint))).to(beTruthy());
@@ -763,7 +765,7 @@ describe(@"SDLTouchManager Tests", ^{
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, pinchStartCenter))).to(beTruthy());
@@ -788,7 +790,7 @@ describe(@"SDLTouchManager Tests", ^{
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, pinchEndCenter))).to(beTruthy());
@@ -813,7 +815,7 @@ describe(@"SDLTouchManager Tests", ^{
__unsafe_unretained SDLTouchManager* touchManagerCallback;
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, pinchStartCenter))).to(beTruthy());
@@ -845,7 +847,7 @@ describe(@"SDLTouchManager Tests", ^{
__unsafe_unretained SDLTouchManager* touchManagerCallback;
CGPoint point;
[invocation getArgument:&touchManagerCallback atIndex:2];
- [invocation getArgument:&point atIndex:3];
+ [invocation getArgument:&point atIndex:4];
expect(touchManagerCallback).to(equal(touchManager));
expect(@(CGPointEqualToPoint(point, pinchStartCenter))).to(beTruthy());