summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuller, Alexander (A.) <amulle19@ford.com>2016-07-01 18:15:10 -0400
committerMuller, Alexander (A.) <amulle19@ford.com>2016-07-01 18:15:10 -0400
commitc8d0846b78423130a4296fdc2131dfc098e2ec03 (patch)
treefeeee55ba7624062bde2b117e744d16a8f8039e1
parentb11680bcd591572baec21d9638bb799ce93fa5c6 (diff)
downloadsdl_ios-c8d0846b78423130a4296fdc2131dfc098e2ec03.tar.gz
Moved all helper class tests to separate files.
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj24
-rw-r--r--SmartDeviceLinkTests/UtilitiesSpecs/Touches/CGPointUtilSpec.m102
-rw-r--r--SmartDeviceLinkTests/UtilitiesSpecs/Touches/DispatchTimerSpec.m47
-rw-r--r--SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLPinchGestureSpec.m128
-rw-r--r--SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m (renamed from SmartDeviceLinkTests/SDLTouchManagerSpec.m)303
-rw-r--r--SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchSpec.m99
6 files changed, 396 insertions, 307 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index 32807e6e9..2f9416c14 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -786,7 +786,11 @@
5DEE55C51B864AB3004F0D0F /* OHHTTPStubs.framework.dSYM in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5DEE55C41B864AB3004F0D0F /* OHHTTPStubs.framework.dSYM */; };
5DEE55C61B8666A8004F0D0F /* OHHTTPStubs.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5DEE55C11B864A7D004F0D0F /* OHHTTPStubs.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
5DF2BB9D1B94E38A00CE5994 /* SDLURLSessionSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5DF2BB9C1B94E38A00CE5994 /* SDLURLSessionSpec.m */; };
- DA1166DB1D14625200438CEA /* SDLTouchManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA1166DA1D14625200438CEA /* SDLTouchManagerSpec.m */; };
+ DA4353DF1D271FD10099B8C4 /* CGPointUtilSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353DE1D271FD10099B8C4 /* CGPointUtilSpec.m */; };
+ DA4353E31D2720A30099B8C4 /* SDLPinchGestureSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E21D2720A30099B8C4 /* SDLPinchGestureSpec.m */; };
+ DA4353E91D2721680099B8C4 /* DispatchTimerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E61D2721680099B8C4 /* DispatchTimerSpec.m */; };
+ DA4353EA1D2721680099B8C4 /* SDLTouchManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E71D2721680099B8C4 /* SDLTouchManagerSpec.m */; };
+ DA4353EB1D2721680099B8C4 /* SDLTouchSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4353E81D2721680099B8C4 /* SDLTouchSpec.m */; };
DAC572571D1067270004288B /* SDLTouchManager.h in Headers */ = {isa = PBXBuildFile; fileRef = DAC572551D1067270004288B /* SDLTouchManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
DAC572581D1067270004288B /* SDLTouchManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DAC572561D1067270004288B /* SDLTouchManager.m */; };
DAC5725B1D10B81E0004288B /* SDLTouch.m in Sources */ = {isa = PBXBuildFile; fileRef = DAC572591D10B81E0004288B /* SDLTouch.m */; };
@@ -1676,7 +1680,11 @@
5DEE55C11B864A7D004F0D0F /* OHHTTPStubs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OHHTTPStubs.framework; path = Carthage/Build/iOS/OHHTTPStubs.framework; sourceTree = "<group>"; };
5DEE55C41B864AB3004F0D0F /* OHHTTPStubs.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = OHHTTPStubs.framework.dSYM; path = Carthage/Build/iOS/OHHTTPStubs.framework.dSYM; sourceTree = "<group>"; };
5DF2BB9C1B94E38A00CE5994 /* SDLURLSessionSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLURLSessionSpec.m; path = "UtilitiesSpecs/HTTP Connection/SDLURLSessionSpec.m"; sourceTree = "<group>"; };
- DA1166DA1D14625200438CEA /* SDLTouchManagerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLTouchManagerSpec.m; sourceTree = "<group>"; };
+ DA4353DE1D271FD10099B8C4 /* CGPointUtilSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CGPointUtilSpec.m; path = UtilitiesSpecs/Touches/CGPointUtilSpec.m; sourceTree = "<group>"; };
+ DA4353E21D2720A30099B8C4 /* SDLPinchGestureSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLPinchGestureSpec.m; path = UtilitiesSpecs/Touches/SDLPinchGestureSpec.m; sourceTree = "<group>"; };
+ DA4353E61D2721680099B8C4 /* DispatchTimerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DispatchTimerSpec.m; path = UtilitiesSpecs/Touches/DispatchTimerSpec.m; sourceTree = "<group>"; };
+ DA4353E71D2721680099B8C4 /* SDLTouchManagerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLTouchManagerSpec.m; path = UtilitiesSpecs/Touches/SDLTouchManagerSpec.m; sourceTree = "<group>"; };
+ DA4353E81D2721680099B8C4 /* SDLTouchSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLTouchSpec.m; path = UtilitiesSpecs/Touches/SDLTouchSpec.m; sourceTree = "<group>"; };
DAC572551D1067270004288B /* SDLTouchManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLTouchManager.h; sourceTree = "<group>"; };
DAC572561D1067270004288B /* SDLTouchManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLTouchManager.m; sourceTree = "<group>"; };
DAC572591D10B81E0004288B /* SDLTouch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLTouch.m; sourceTree = "<group>"; };
@@ -2987,7 +2995,11 @@
DA1166D71D14601C00438CEA /* Touches */ = {
isa = PBXGroup;
children = (
- DA1166DA1D14625200438CEA /* SDLTouchManagerSpec.m */,
+ DA4353E61D2721680099B8C4 /* DispatchTimerSpec.m */,
+ DA4353E71D2721680099B8C4 /* SDLTouchManagerSpec.m */,
+ DA4353E81D2721680099B8C4 /* SDLTouchSpec.m */,
+ DA4353DE1D271FD10099B8C4 /* CGPointUtilSpec.m */,
+ DA4353E21D2720A30099B8C4 /* SDLPinchGestureSpec.m */,
);
name = Touches;
sourceTree = "<group>";
@@ -3810,6 +3822,7 @@
162E83811A9BDE8B00906325 /* SDLImageFieldSpec.m in Sources */,
162E834F1A9BDE8B00906325 /* SDLDeleteCommandResponseSpec.m in Sources */,
162E83231A9BDE8B00906325 /* SDLAddSubMenuSpec.m in Sources */,
+ DA4353E91D2721680099B8C4 /* DispatchTimerSpec.m in Sources */,
162E82F21A9BDE8B00906325 /* SDLPredefinedLayoutSpec.m in Sources */,
162E83521A9BDE8B00906325 /* SDLDeleteSubMenuResponseSpec.m in Sources */,
162E82E91A9BDE8B00906325 /* SDLKeypressModeSpec.m in Sources */,
@@ -3822,7 +3835,6 @@
162E83341A9BDE8B00906325 /* SDLPutFileSpec.m in Sources */,
162E837A1A9BDE8B00906325 /* SDLDIDResult.m in Sources */,
162E83171A9BDE8B00906325 /* SDLOnHMIStatusSpec.m in Sources */,
- DA1166DB1D14625200438CEA /* SDLTouchManagerSpec.m in Sources */,
5DE372A41ACB336600849FAA /* SDLHMICapabilitiesSpec.m in Sources */,
162E82F71A9BDE8B00906325 /* SDLResultSpec.m in Sources */,
1680B1141A9CD7AD00DBD79E /* SDLV1ProtocolHeaderSpec.m in Sources */,
@@ -3832,6 +3844,7 @@
162E83831A9BDE8B00906325 /* SDLKeyboardPropertiesSpec.m in Sources */,
162E82D11A9BDE8A00906325 /* SDLButtonNameSpec.m in Sources */,
162E839E1A9BDE8B00906325 /* SDLRPCStructSpec.m in Sources */,
+ DA4353DF1D271FD10099B8C4 /* CGPointUtilSpec.m in Sources */,
162E83291A9BDE8B00906325 /* SDLDeleteFileSpec.m in Sources */,
1680B11D1A9CD7AD00DBD79E /* SDLProtocolMessageDisassemblerSpec.m in Sources */,
162E838E1A9BDE8B00906325 /* SDLSyncMsgVersionSpec.m in Sources */,
@@ -3865,6 +3878,7 @@
5DF2BB9D1B94E38A00CE5994 /* SDLURLSessionSpec.m in Sources */,
162E83381A9BDE8B00906325 /* SDLScrollableMessageSpec.m in Sources */,
162E82E81A9BDE8B00906325 /* SDLKeyboardLayoutSpec.m in Sources */,
+ DA4353EB1D2721680099B8C4 /* SDLTouchSpec.m in Sources */,
162E83541A9BDE8B00906325 /* SDLEncodedSyncPDataResponseSpec.m in Sources */,
162E83161A9BDE8B00906325 /* SDLOnHashChangeSpec.m in Sources */,
162E82FE1A9BDE8B00906325 /* SDLTBTStateSpec.m in Sources */,
@@ -3890,6 +3904,7 @@
162E83741A9BDE8B00906325 /* SDLBodyInformationSpec.m in Sources */,
162E83641A9BDE8B00906325 /* SDLSetMediaClockTimerResponseSpec.m in Sources */,
162E839C1A9BDE8B00906325 /* SDLRPCRequestSpec.m in Sources */,
+ DA4353E31D2720A30099B8C4 /* SDLPinchGestureSpec.m in Sources */,
5D8B17561AC9E399006A6E1C /* SDLDialNumberSpec.m in Sources */,
162E833D1A9BDE8B00906325 /* SDLShowConstantTBTSpec.m in Sources */,
162E83651A9BDE8B00906325 /* SDLShowConstantTBTResponseSpec.m in Sources */,
@@ -3939,6 +3954,7 @@
162E83891A9BDE8B00906325 /* SDLScreenParamsSpec.m in Sources */,
162E83441A9BDE8B00906325 /* SDLSystemRequestSpec.m in Sources */,
162E83001A9BDE8B00906325 /* SDLTextFieldNameSpec.m in Sources */,
+ DA4353EA1D2721680099B8C4 /* SDLTouchManagerSpec.m in Sources */,
162E82FC1A9BDE8B00906325 /* SDLSystemAction.m in Sources */,
162E82CC1A9BDE8A00906325 /* SDLAppInterfaceUnregisteredReasonSpec.m in Sources */,
162E83321A9BDE8B00906325 /* SDLPerformAudioPassThruSpec.m in Sources */,
diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/CGPointUtilSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/CGPointUtilSpec.m
new file mode 100644
index 000000000..a58419ee3
--- /dev/null
+++ b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/CGPointUtilSpec.m
@@ -0,0 +1,102 @@
+//
+// CGPointUtilSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Muller, Alexander (A.) on 7/1/16.
+// Copyright © 2016 smartdevicelink. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+#import <OCMock/OCMock.h>
+
+#import "CGPoint_Util.h"
+
+QuickSpecBegin(CGPointUtilSpec)
+
+describe(@"CGPoint_Util Tests", ^{
+ __block CGPoint first;
+ __block CGPoint second;
+ context(@"For two positive points", ^{
+ beforeEach(^{
+ first = CGPointMake(100, 200);
+ second = CGPointMake(300, 400);
+ });
+
+ it(@"should properly calculate the average between points", ^{
+ CGPoint average = CGPointAverageOfPoints(first, second);
+ expect(@(average.x)).to(equal(@200));
+ expect(@(average.y)).to(equal(@300));
+ });
+ it(@"should properly calculate the center between points", ^{
+ CGPoint center = CGPointCenterOfPoints(first, second);
+ expect(@(center.x)).to(equal(@200));
+ expect(@(center.y)).to(equal(@300));
+ });
+ it(@"should properly calculate the displacement between points", ^{
+ CGPoint displacement = CGPointDisplacementOfPoints(first, second);
+ expect(@(displacement.x)).to(equal(@(-200)));
+ expect(@(displacement.y)).to(equal(@(-200)));
+ });
+ it(@"should properly calculate the distance between points", ^{
+ CGFloat distance = CGPointDistanceBetweenPoints(first, second);
+ expect(@(distance)).to(beCloseTo(@282.8427).within(0.0001));
+ });
+ });
+ context(@"For two negative points", ^{
+ beforeEach(^{
+ first = CGPointMake(-100, -200);
+ second = CGPointMake(-300, -400);
+ });
+
+ it(@"should properly calculate the average between points", ^{
+ CGPoint average = CGPointAverageOfPoints(first, second);
+ expect(@(average.x)).to(equal(@(-200)));
+ expect(@(average.y)).to(equal(@(-300)));
+ });
+ it(@"should properly calculate the center between points", ^{
+ CGPoint center = CGPointCenterOfPoints(first, second);
+ expect(@(center.x)).to(equal(@(-200)));
+ expect(@(center.y)).to(equal(@(-300)));
+ });
+ it(@"should properly calculate the displacement between points", ^{
+ CGPoint displacement = CGPointDisplacementOfPoints(first, second);
+ expect(@(displacement.x)).to(equal(@200));
+ expect(@(displacement.y)).to(equal(@200));
+ });
+ it(@"should properly calculate the distance between points", ^{
+ CGFloat distance = CGPointDistanceBetweenPoints(first, second);
+ expect(@(distance)).to(beCloseTo(@282.8427).within(0.0001));
+ });
+ });
+ context(@"For one positive and one negative point", ^{
+ beforeEach(^{
+ first = CGPointMake(100, 200);
+ second = CGPointMake(-300, -400);
+ });
+
+ it(@"should properly calculate the average between points", ^{
+ CGPoint average = CGPointAverageOfPoints(first, second);
+ expect(@(average.x)).to(equal(@(-100)));
+ expect(@(average.y)).to(equal(@(-100)));
+ });
+ it(@"should properly calculate the center between points", ^{
+ CGPoint center = CGPointCenterOfPoints(first, second);
+ expect(@(center.x)).to(equal(@(-100)));
+ expect(@(center.y)).to(equal(@(-100)));
+ });
+ it(@"should properly calculate the displacement between points", ^{
+ CGPoint displacement = CGPointDisplacementOfPoints(first, second);
+ expect(@(displacement.x)).to(equal(@400));
+ expect(@(displacement.y)).to(equal(@600));
+ });
+ it(@"should properly calculate the distance between points", ^{
+ CGFloat distance = CGPointDistanceBetweenPoints(first, second);
+ expect(@(distance)).to(beCloseTo(@721.1103).within(0.0001));
+ });
+ });
+});
+
+QuickSpecEnd \ No newline at end of file
diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/DispatchTimerSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/DispatchTimerSpec.m
new file mode 100644
index 000000000..771d2c4bb
--- /dev/null
+++ b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/DispatchTimerSpec.m
@@ -0,0 +1,47 @@
+//
+// DispatchTimerSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Muller, Alexander (A.) on 7/1/16.
+// Copyright © 2016 smartdevicelink. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+#import <OCMock/OCMock.h>
+
+#import "dispatch_timer.h"
+
+QuickSpecBegin(DispatchTimerSpec)
+
+describe(@"dispatch_timer Tests", ^{
+ context(@"Creating", ^{
+ it(@"should be successful within specified time", ^{
+ waitUntilTimeout(4, ^(void (^done)(void)) {
+ __block double currentTime = [[NSDate date] timeIntervalSince1970];
+ dispatch_create_timer(2.5, false, ^{
+ double difference = [[NSDate date] timeIntervalSince1970] - currentTime;
+ expect(@(difference)).to(beCloseTo(@2.5).within(0.1));
+ done();
+ });
+ });
+ });
+
+ it(@"should be cancellable and not fire", ^{
+ __block dispatch_source_t timer;
+ waitUntilTimeout(2, ^(void (^done)(void)) {
+ timer = dispatch_create_timer(2.5, false, ^{
+ fail();
+ });
+ [NSThread sleepForTimeInterval:0.5];
+ dispatch_stop_timer(timer);
+ done();
+ });
+ expect(@(dispatch_source_testcancel(timer))).to(beGreaterThan(@0));
+ });
+ });
+});
+
+QuickSpecEnd \ No newline at end of file
diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLPinchGestureSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLPinchGestureSpec.m
new file mode 100644
index 000000000..1a41b537d
--- /dev/null
+++ b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLPinchGestureSpec.m
@@ -0,0 +1,128 @@
+//
+// SDLPinchGestureSpec.m
+// SmartDeviceLink-iOS
+//
+// Created by Muller, Alexander (A.) on 7/1/16.
+// Copyright © 2016 smartdevicelink. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+#import <OCMock/OCMock.h>
+
+#import "SDLPinchGesture.h"
+
+QuickSpecBegin(SDLPinchGestureSpec)
+
+describe(@"SDLPinchGesture Tests", ^{
+ context(@"SDLPinchGestureZero", ^{
+ __block SDLPinchGesture pinchGesture = SDLPinchGestureZero;
+
+ it(@"should correctly initialize", ^{
+ expect(@(pinchGesture.firstTouch.identifier)).to(equal(@(-1)));
+ expect(@(pinchGesture.firstTouch.location.x)).to(equal(@0));
+ expect(@(pinchGesture.firstTouch.location.y)).to(equal(@0));
+ expect(@(pinchGesture.firstTouch.timeStamp)).to(equal(@0));
+
+ expect(@(pinchGesture.secondTouch.identifier)).to(equal(@(-1)));
+ expect(@(pinchGesture.secondTouch.location.x)).to(equal(@0));
+ expect(@(pinchGesture.secondTouch.location.y)).to(equal(@0));
+ expect(@(pinchGesture.secondTouch.timeStamp)).to(equal(@0));
+ });
+
+ it(@"should not be a valid SDLPinchGesture", ^{
+ expect(@(SDLPinchGestureIsValid(pinchGesture))).to(beFalsy());
+ });
+ });
+
+ context(@"SDLPinchGestureMake", ^{
+ __block SDLPinchGesture pinchGesture;
+ __block SDLTouch firstTouch;
+ __block SDLTouch secondTouch;
+ __block unsigned long timeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
+ __block unsigned long secondTimeStamp = timeStamp + 1000;
+
+ beforeEach(^{
+ firstTouch = SDLTouchMake(SDLTouchIdentifierFirstFinger, 100, 200, timeStamp);
+ secondTouch = SDLTouchMake(SDLTouchIdentifierSecondFinger, 200, 300, secondTimeStamp);
+ pinchGesture = SDLPinchGestureMake(firstTouch, secondTouch);
+ });
+
+ it(@"should correctly initialize", ^{
+ expect(@(pinchGesture.firstTouch.identifier)).to(equal(@(SDLTouchIdentifierFirstFinger)));
+ expect(@(pinchGesture.firstTouch.location.x)).to(equal(@100));
+ expect(@(pinchGesture.firstTouch.location.y)).to(equal(@200));
+ expect(@(pinchGesture.firstTouch.timeStamp)).to(equal(@(timeStamp)));
+
+ expect(@(pinchGesture.secondTouch.identifier)).to(equal(@(SDLTouchIdentifierSecondFinger)));
+ expect(@(pinchGesture.secondTouch.location.x)).to(equal(@200));
+ expect(@(pinchGesture.secondTouch.location.y)).to(equal(@300));
+ expect(@(pinchGesture.secondTouch.timeStamp)).to(equal(@(secondTimeStamp)));
+
+ expect(@(pinchGesture.distance)).to(beCloseTo(@141.4213).within(0.0001));
+ expect(@(pinchGesture.center.x)).to(equal(@150));
+ expect(@(pinchGesture.center.y)).to(equal(@250));
+ });
+
+ it(@"should be a valid SDLPinchGesture", ^{
+ expect(@(SDLPinchGestureIsValid(pinchGesture))).to(beTruthy());
+ });
+ });
+
+ context(@"updating SDLPinchGesture", ^{
+ __block SDLPinchGesture pinchGesture;
+ __block unsigned long timeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
+ __block unsigned long secondTimeStamp = timeStamp + 1000;
+
+ beforeEach(^{
+ SDLTouch firstTouch = SDLTouchMake(SDLTouchIdentifierFirstFinger, 100, 200, timeStamp);
+ SDLTouch secondTouch = SDLTouchMake(SDLTouchIdentifierSecondFinger, 200, 300, secondTimeStamp);
+ pinchGesture = SDLPinchGestureMake(firstTouch, secondTouch);
+ });
+
+ it(@"should update first point correctly", ^{
+ unsigned long newTimeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
+ SDLTouch newTouch = SDLTouchMake(SDLTouchIdentifierFirstFinger, 150, 250, newTimeStamp);
+ pinchGesture = SDLPinchGestureUpdateFromTouch(pinchGesture, newTouch);
+
+ expect(@(pinchGesture.firstTouch.identifier)).to(equal(@(SDLTouchIdentifierFirstFinger)));
+ expect(@(pinchGesture.firstTouch.location.x)).to(equal(@150));
+ expect(@(pinchGesture.firstTouch.location.y)).to(equal(@250));
+ expect(@(pinchGesture.firstTouch.timeStamp)).to(equal(@(newTimeStamp)));
+
+ expect(@(pinchGesture.secondTouch.identifier)).to(equal(@(SDLTouchIdentifierSecondFinger)));
+ expect(@(pinchGesture.secondTouch.location.x)).to(equal(@200));
+ expect(@(pinchGesture.secondTouch.location.y)).to(equal(@300));
+ expect(@(pinchGesture.secondTouch.timeStamp)).to(equal(@(secondTimeStamp)));
+
+ expect(@(pinchGesture.distance)).to(beCloseTo(@(70.7107)).within(0.0001));
+ expect(@(pinchGesture.center.x)).to(equal(@175));
+ expect(@(pinchGesture.center.y)).to(equal(@275));
+
+ });
+
+ it(@"should update second point correctly", ^{
+ unsigned long newTimeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
+ SDLTouch newTouch = SDLTouchMake(SDLTouchIdentifierSecondFinger, 150, 250, newTimeStamp);
+ pinchGesture = SDLPinchGestureUpdateFromTouch(pinchGesture, newTouch);
+
+ expect(@(pinchGesture.firstTouch.identifier)).to(equal(@(SDLTouchIdentifierFirstFinger)));
+ expect(@(pinchGesture.firstTouch.location.x)).to(equal(@100));
+ expect(@(pinchGesture.firstTouch.location.y)).to(equal(@200));
+ expect(@(pinchGesture.firstTouch.timeStamp)).to(equal(@(timeStamp)));
+
+ expect(@(pinchGesture.secondTouch.identifier)).to(equal(@(SDLTouchIdentifierSecondFinger)));
+ expect(@(pinchGesture.secondTouch.location.x)).to(equal(@150));
+ expect(@(pinchGesture.secondTouch.location.y)).to(equal(@250));
+ expect(@(pinchGesture.secondTouch.timeStamp)).to(equal(@(newTimeStamp)));
+
+ expect(@(pinchGesture.distance)).to(beCloseTo(@70.7107).within(0.0001));
+ expect(@(pinchGesture.center.x)).to(equal(@125));
+ expect(@(pinchGesture.center.y)).to(equal(@225));
+ });
+ });
+});
+
+QuickSpecEnd \ No newline at end of file
diff --git a/SmartDeviceLinkTests/SDLTouchManagerSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m
index 0bf22f41e..f26c4650c 100644
--- a/SmartDeviceLinkTests/SDLTouchManagerSpec.m
+++ b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m
@@ -18,314 +18,11 @@
#import "SDLTouchManager.h"
#import "SDLTouchType.h"
#import "CGPoint_Util.h"
-#import "SDLTouch.h"
-#import "SDLPinchGesture.h"
-#import "dispatch_timer.h"
QuickSpecBegin(SDLTouchManagerSpec)
typedef void (^DelegateCallbackBlock)(NSInvocation* invocation);
-describe(@"CGPoint_Util Tests", ^{
- __block CGPoint first;
- __block CGPoint second;
- context(@"For two positive points", ^{
- beforeEach(^{
- first = CGPointMake(100, 200);
- second = CGPointMake(300, 400);
- });
-
- it(@"should properly calculate the average between points", ^{
- CGPoint average = CGPointAverageOfPoints(first, second);
- expect(@(average.x)).to(equal(@200));
- expect(@(average.y)).to(equal(@300));
- });
- it(@"should properly calculate the center between points", ^{
- CGPoint center = CGPointCenterOfPoints(first, second);
- expect(@(center.x)).to(equal(@200));
- expect(@(center.y)).to(equal(@300));
- });
- it(@"should properly calculate the displacement between points", ^{
- CGPoint displacement = CGPointDisplacementOfPoints(first, second);
- expect(@(displacement.x)).to(equal(@(-200)));
- expect(@(displacement.y)).to(equal(@(-200)));
- });
- it(@"should properly calculate the distance between points", ^{
- CGFloat distance = CGPointDistanceBetweenPoints(first, second);
- expect(@(distance)).to(beCloseTo(@282.8427).within(0.0001));
- });
- });
- context(@"For two negative points", ^{
- beforeEach(^{
- first = CGPointMake(-100, -200);
- second = CGPointMake(-300, -400);
- });
-
- it(@"should properly calculate the average between points", ^{
- CGPoint average = CGPointAverageOfPoints(first, second);
- expect(@(average.x)).to(equal(@(-200)));
- expect(@(average.y)).to(equal(@(-300)));
- });
- it(@"should properly calculate the center between points", ^{
- CGPoint center = CGPointCenterOfPoints(first, second);
- expect(@(center.x)).to(equal(@(-200)));
- expect(@(center.y)).to(equal(@(-300)));
- });
- it(@"should properly calculate the displacement between points", ^{
- CGPoint displacement = CGPointDisplacementOfPoints(first, second);
- expect(@(displacement.x)).to(equal(@200));
- expect(@(displacement.y)).to(equal(@200));
- });
- it(@"should properly calculate the distance between points", ^{
- CGFloat distance = CGPointDistanceBetweenPoints(first, second);
- expect(@(distance)).to(beCloseTo(@282.8427).within(0.0001));
- });
- });
- context(@"For one positive and one negative point", ^{
- beforeEach(^{
- first = CGPointMake(100, 200);
- second = CGPointMake(-300, -400);
- });
-
- it(@"should properly calculate the average between points", ^{
- CGPoint average = CGPointAverageOfPoints(first, second);
- expect(@(average.x)).to(equal(@(-100)));
- expect(@(average.y)).to(equal(@(-100)));
- });
- it(@"should properly calculate the center between points", ^{
- CGPoint center = CGPointCenterOfPoints(first, second);
- expect(@(center.x)).to(equal(@(-100)));
- expect(@(center.y)).to(equal(@(-100)));
- });
- it(@"should properly calculate the displacement between points", ^{
- CGPoint displacement = CGPointDisplacementOfPoints(first, second);
- expect(@(displacement.x)).to(equal(@400));
- expect(@(displacement.y)).to(equal(@600));
- });
- it(@"should properly calculate the distance between points", ^{
- CGFloat distance = CGPointDistanceBetweenPoints(first, second);
- expect(@(distance)).to(beCloseTo(@721.1103).within(0.0001));
- });
- });
-});
-
-describe(@"SDLTouch Tests", ^{
- context(@"SDLTouchZero", ^{
- __block SDLTouch touch = SDLTouchZero;
-
- it(@"should correctly initialize", ^{
- expect(@(touch.identifier)).to(equal(@(-1)));
- expect(@(CGPointEqualToPoint(touch.location, CGPointZero))).to(beTruthy());
- expect(@(touch.timeStamp)).to(equal(@0));
- });
-
- it(@"should not be a valid SDLTouch", ^{
- expect(@(SDLTouchIsValid(touch))).to(beFalsy());
- });
-
- it(@"should not equal First Finger Identifier", ^{
- expect(@(SDLTouchIsFirstFinger(touch))).to(beFalsy());
- });
-
- it(@"should not equal Second Finger Identifier", ^{
- expect(@(SDLTouchIsSecondFinger(touch))).to(beFalsy());
- });
- });
-
- context(@"For First Finger Identifiers", ^{
- __block unsigned long timeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
- __block SDLTouch touch;
-
- beforeSuite(^{
- touch = SDLTouchMake(0, 100, 200, timeStamp);
- });
-
- it(@"should correctly make a SDLTouch struct", ^{
- expect(@(touch.identifier)).to(equal(@(SDLTouchIdentifierFirstFinger)));
- expect(@(touch.location.x)).to(equal(@100));
- expect(@(touch.location.y)).to(equal(@200));
- expect(@(touch.timeStamp)).to(equal(@(timeStamp)));
- });
-
- it(@"should be a valid SDLTouch", ^{
- expect(@(SDLTouchIsValid(touch))).to(beTruthy());
- });
-
- it(@"should equal First Finger Identifier", ^{
- expect(@(SDLTouchIsFirstFinger(touch))).to(beTruthy());
- });
-
- it(@"should not equal Second Finger Identifier", ^{
- expect(@(SDLTouchIsSecondFinger(touch))).to(beFalsy());
- });
- });
-
- context(@"For Second Finger Identifiers", ^{
- __block unsigned long timeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
- __block SDLTouch touch;
-
- beforeSuite(^{
- touch = SDLTouchMake(1, 100, 200, timeStamp);
- });
-
- it(@"should correctly make a SDLTouch struct", ^{
- expect(@(touch.identifier)).to(equal(@(SDLTouchIdentifierSecondFinger)));
- expect(@(touch.location.x)).to(equal(@100));
- expect(@(touch.location.y)).to(equal(@200));
- expect(@(touch.timeStamp)).to(equal(@(timeStamp)));
- });
-
- it(@"should be a valid SDLTouch", ^{
- expect(@(SDLTouchIsValid(touch))).to(beTruthy());
- });
-
- it(@"should equal First Finger Identifier", ^{
- expect(@(SDLTouchIsFirstFinger(touch))).to(beFalsy());
- });
-
- it(@"should not equal Second Finger Identifier", ^{
- expect(@(SDLTouchIsSecondFinger(touch))).to(beTruthy());
- });
- });
-});
-
-describe(@"SDLPinchGesture Tests", ^{
- context(@"SDLPinchGestureZero", ^{
- __block SDLPinchGesture pinchGesture = SDLPinchGestureZero;
-
- it(@"should correctly initialize", ^{
- expect(@(pinchGesture.firstTouch.identifier)).to(equal(@(-1)));
- expect(@(pinchGesture.firstTouch.location.x)).to(equal(@0));
- expect(@(pinchGesture.firstTouch.location.y)).to(equal(@0));
- expect(@(pinchGesture.firstTouch.timeStamp)).to(equal(@0));
-
- expect(@(pinchGesture.secondTouch.identifier)).to(equal(@(-1)));
- expect(@(pinchGesture.secondTouch.location.x)).to(equal(@0));
- expect(@(pinchGesture.secondTouch.location.y)).to(equal(@0));
- expect(@(pinchGesture.secondTouch.timeStamp)).to(equal(@0));
- });
-
- it(@"should not be a valid SDLPinchGesture", ^{
- expect(@(SDLPinchGestureIsValid(pinchGesture))).to(beFalsy());
- });
- });
-
- context(@"SDLPinchGestureMake", ^{
- __block SDLPinchGesture pinchGesture;
- __block SDLTouch firstTouch;
- __block SDLTouch secondTouch;
- __block unsigned long timeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
- __block unsigned long secondTimeStamp = timeStamp + 1000;
-
- beforeEach(^{
- firstTouch = SDLTouchMake(SDLTouchIdentifierFirstFinger, 100, 200, timeStamp);
- secondTouch = SDLTouchMake(SDLTouchIdentifierSecondFinger, 200, 300, secondTimeStamp);
- pinchGesture = SDLPinchGestureMake(firstTouch, secondTouch);
- });
-
- it(@"should correctly initialize", ^{
- expect(@(pinchGesture.firstTouch.identifier)).to(equal(@(SDLTouchIdentifierFirstFinger)));
- expect(@(pinchGesture.firstTouch.location.x)).to(equal(@100));
- expect(@(pinchGesture.firstTouch.location.y)).to(equal(@200));
- expect(@(pinchGesture.firstTouch.timeStamp)).to(equal(@(timeStamp)));
-
- expect(@(pinchGesture.secondTouch.identifier)).to(equal(@(SDLTouchIdentifierSecondFinger)));
- expect(@(pinchGesture.secondTouch.location.x)).to(equal(@200));
- expect(@(pinchGesture.secondTouch.location.y)).to(equal(@300));
- expect(@(pinchGesture.secondTouch.timeStamp)).to(equal(@(secondTimeStamp)));
-
- expect(@(pinchGesture.distance)).to(beCloseTo(@141.4213).within(0.0001));
- expect(@(pinchGesture.center.x)).to(equal(@150));
- expect(@(pinchGesture.center.y)).to(equal(@250));
- });
-
- it(@"should be a valid SDLPinchGesture", ^{
- expect(@(SDLPinchGestureIsValid(pinchGesture))).to(beTruthy());
- });
- });
-
- context(@"updating SDLPinchGesture", ^{
- __block SDLPinchGesture pinchGesture;
- __block unsigned long timeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
- __block unsigned long secondTimeStamp = timeStamp + 1000;
-
- beforeEach(^{
- SDLTouch firstTouch = SDLTouchMake(SDLTouchIdentifierFirstFinger, 100, 200, timeStamp);
- SDLTouch secondTouch = SDLTouchMake(SDLTouchIdentifierSecondFinger, 200, 300, secondTimeStamp);
- pinchGesture = SDLPinchGestureMake(firstTouch, secondTouch);
- });
-
- it(@"should update first point correctly", ^{
- unsigned long newTimeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
- SDLTouch newTouch = SDLTouchMake(SDLTouchIdentifierFirstFinger, 150, 250, newTimeStamp);
- pinchGesture = SDLPinchGestureUpdateFromTouch(pinchGesture, newTouch);
-
- expect(@(pinchGesture.firstTouch.identifier)).to(equal(@(SDLTouchIdentifierFirstFinger)));
- expect(@(pinchGesture.firstTouch.location.x)).to(equal(@150));
- expect(@(pinchGesture.firstTouch.location.y)).to(equal(@250));
- expect(@(pinchGesture.firstTouch.timeStamp)).to(equal(@(newTimeStamp)));
-
- expect(@(pinchGesture.secondTouch.identifier)).to(equal(@(SDLTouchIdentifierSecondFinger)));
- expect(@(pinchGesture.secondTouch.location.x)).to(equal(@200));
- expect(@(pinchGesture.secondTouch.location.y)).to(equal(@300));
- expect(@(pinchGesture.secondTouch.timeStamp)).to(equal(@(secondTimeStamp)));
-
- expect(@(pinchGesture.distance)).to(beCloseTo(@(70.7107)).within(0.0001));
- expect(@(pinchGesture.center.x)).to(equal(@175));
- expect(@(pinchGesture.center.y)).to(equal(@275));
-
- });
-
- it(@"should update second point correctly", ^{
- unsigned long newTimeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
- SDLTouch newTouch = SDLTouchMake(SDLTouchIdentifierSecondFinger, 150, 250, newTimeStamp);
- pinchGesture = SDLPinchGestureUpdateFromTouch(pinchGesture, newTouch);
-
- expect(@(pinchGesture.firstTouch.identifier)).to(equal(@(SDLTouchIdentifierFirstFinger)));
- expect(@(pinchGesture.firstTouch.location.x)).to(equal(@100));
- expect(@(pinchGesture.firstTouch.location.y)).to(equal(@200));
- expect(@(pinchGesture.firstTouch.timeStamp)).to(equal(@(timeStamp)));
-
- expect(@(pinchGesture.secondTouch.identifier)).to(equal(@(SDLTouchIdentifierSecondFinger)));
- expect(@(pinchGesture.secondTouch.location.x)).to(equal(@150));
- expect(@(pinchGesture.secondTouch.location.y)).to(equal(@250));
- expect(@(pinchGesture.secondTouch.timeStamp)).to(equal(@(newTimeStamp)));
-
- expect(@(pinchGesture.distance)).to(beCloseTo(@70.7107).within(0.0001));
- expect(@(pinchGesture.center.x)).to(equal(@125));
- expect(@(pinchGesture.center.y)).to(equal(@225));
- });
- });
-});
-
-describe(@"dispatch_timer Tests", ^{
- context(@"Creating", ^{
- it(@"should be successful within specified time", ^{
- waitUntilTimeout(4, ^(void (^done)(void)) {
- __block double currentTime = [[NSDate date] timeIntervalSince1970];
- dispatch_create_timer(2.5, false, ^{
- double difference = [[NSDate date] timeIntervalSince1970] - currentTime;
- expect(@(difference)).to(beCloseTo(@2.5).within(0.1));
- done();
- });
- });
- });
-
- it(@"should be cancellable and not fire", ^{
- __block dispatch_source_t timer;
- waitUntilTimeout(2, ^(void (^done)(void)) {
- timer = dispatch_create_timer(2.5, false, ^{
- fail();
- });
- [NSThread sleepForTimeInterval:0.5];
- dispatch_stop_timer(timer);
- done();
- });
- expect(@(dispatch_source_testcancel(timer))).to(beGreaterThan(@0));
- });
- });
-});
-
describe(@"SDLTouchManager Tests", ^{
__block SDLTouchManager* touchManager;
diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchSpec.m
new file mode 100644
index 000000000..4831f7d3c
--- /dev/null
+++ b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchSpec.m
@@ -0,0 +1,99 @@
+//
+// SDLTouchSpecs.m
+// SmartDeviceLink-iOS
+//
+// Created by Muller, Alexander (A.) on 7/1/16.
+// Copyright © 2016 smartdevicelink. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+#import <OCMock/OCMock.h>
+
+#import "SDLTouch.h"
+
+QuickSpecBegin(SDLTouchSpec)
+
+describe(@"SDLTouch Tests", ^{
+ context(@"SDLTouchZero", ^{
+ __block SDLTouch touch = SDLTouchZero;
+
+ it(@"should correctly initialize", ^{
+ expect(@(touch.identifier)).to(equal(@(-1)));
+ expect(@(CGPointEqualToPoint(touch.location, CGPointZero))).to(beTruthy());
+ expect(@(touch.timeStamp)).to(equal(@0));
+ });
+
+ it(@"should not be a valid SDLTouch", ^{
+ expect(@(SDLTouchIsValid(touch))).to(beFalsy());
+ });
+
+ it(@"should not equal First Finger Identifier", ^{
+ expect(@(SDLTouchIsFirstFinger(touch))).to(beFalsy());
+ });
+
+ it(@"should not equal Second Finger Identifier", ^{
+ expect(@(SDLTouchIsSecondFinger(touch))).to(beFalsy());
+ });
+ });
+
+ context(@"For First Finger Identifiers", ^{
+ __block unsigned long timeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
+ __block SDLTouch touch;
+
+ beforeSuite(^{
+ touch = SDLTouchMake(0, 100, 200, timeStamp);
+ });
+
+ it(@"should correctly make a SDLTouch struct", ^{
+ expect(@(touch.identifier)).to(equal(@(SDLTouchIdentifierFirstFinger)));
+ expect(@(touch.location.x)).to(equal(@100));
+ expect(@(touch.location.y)).to(equal(@200));
+ expect(@(touch.timeStamp)).to(equal(@(timeStamp)));
+ });
+
+ it(@"should be a valid SDLTouch", ^{
+ expect(@(SDLTouchIsValid(touch))).to(beTruthy());
+ });
+
+ it(@"should equal First Finger Identifier", ^{
+ expect(@(SDLTouchIsFirstFinger(touch))).to(beTruthy());
+ });
+
+ it(@"should not equal Second Finger Identifier", ^{
+ expect(@(SDLTouchIsSecondFinger(touch))).to(beFalsy());
+ });
+ });
+
+ context(@"For Second Finger Identifiers", ^{
+ __block unsigned long timeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
+ __block SDLTouch touch;
+
+ beforeSuite(^{
+ touch = SDLTouchMake(1, 100, 200, timeStamp);
+ });
+
+ it(@"should correctly make a SDLTouch struct", ^{
+ expect(@(touch.identifier)).to(equal(@(SDLTouchIdentifierSecondFinger)));
+ expect(@(touch.location.x)).to(equal(@100));
+ expect(@(touch.location.y)).to(equal(@200));
+ expect(@(touch.timeStamp)).to(equal(@(timeStamp)));
+ });
+
+ it(@"should be a valid SDLTouch", ^{
+ expect(@(SDLTouchIsValid(touch))).to(beTruthy());
+ });
+
+ it(@"should equal First Finger Identifier", ^{
+ expect(@(SDLTouchIsFirstFinger(touch))).to(beFalsy());
+ });
+
+ it(@"should not equal Second Finger Identifier", ^{
+ expect(@(SDLTouchIsSecondFinger(touch))).to(beTruthy());
+ });
+ });
+});
+
+QuickSpecEnd \ No newline at end of file