Merge pull request #127 from lightsprint09/tests
Tests for socket.io client
This commit is contained in:
commit
137fd1229b
2
.gitignore
vendored
2
.gitignore
vendored
@ -42,3 +42,5 @@ DerivedData
|
|||||||
*.hmap
|
*.hmap
|
||||||
*.ipa
|
*.ipa
|
||||||
*.xcuserstate
|
*.xcuserstate
|
||||||
|
|
||||||
|
Socket.IO-Test-Server/node_modules/*
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
||||||
572EF22C1B51F16C00EEBB58 /* SocketIO_iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572EF22B1B51F16C00EEBB58 /* SocketIO_iOSTests.swift */; };
|
|
||||||
572EF23D1B51F18A00EEBB58 /* SocketIO-Mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
572EF23D1B51F18A00EEBB58 /* SocketIO-Mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; };
|
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; };
|
||||||
572EF24A1B51F18A00EEBB58 /* SocketIO_MacTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572EF2491B51F18A00EEBB58 /* SocketIO_MacTests.swift */; };
|
572EF24A1B51F18A00EEBB58 /* SocketIO_MacTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572EF2491B51F18A00EEBB58 /* SocketIO_MacTests.swift */; };
|
||||||
@ -39,6 +38,26 @@
|
|||||||
5764DFA01B51F254004FF46E /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
5764DFA01B51F254004FF46E /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||||
5764DFA11B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
5764DFA11B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||||
5764DFA21B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
5764DFA21B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||||
|
941A4ABA1B67A56C00C42318 /* TestKind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 941A4AB91B67A56C00C42318 /* TestKind.swift */; };
|
||||||
|
94242BB81B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */; };
|
||||||
|
945B65351B5FCEEA0081E995 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||||
|
945B65361B5FCEEA0081E995 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||||
|
945B65371B5FCEEA0081E995 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
||||||
|
945B65381B5FCEEA0081E995 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */; };
|
||||||
|
945B65391B5FCEEA0081E995 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF801B51F254004FF46E /* SocketEventHandler.swift */; };
|
||||||
|
945B653A1B5FCEEA0081E995 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF811B51F254004FF46E /* SocketFixUTF8.swift */; };
|
||||||
|
945B653B1B5FCEEA0081E995 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF821B51F254004FF46E /* SocketIOClient.swift */; };
|
||||||
|
945B653C1B5FCEEA0081E995 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF831B51F254004FF46E /* SocketLogger.swift */; };
|
||||||
|
945B653D1B5FCEEA0081E995 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF841B51F254004FF46E /* SocketPacket.swift */; };
|
||||||
|
945B653E1B5FCEEA0081E995 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF851B51F254004FF46E /* SocketParser.swift */; };
|
||||||
|
945B653F1B5FCEEA0081E995 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
||||||
|
945B65401B5FCEEA0081E995 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||||
|
945B65411B5FCEEA0081E995 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||||
|
945B65431B63D9DB0081E995 /* SocketEmitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945B65421B63D9DB0081E995 /* SocketEmitTest.swift */; };
|
||||||
|
94ADAC491B652D3300FD79AE /* SocketNamespaceEmitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */; };
|
||||||
|
94ADAC4B1B6632DD00FD79AE /* SocketAcknowledgementTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */; };
|
||||||
|
94CB8F0B1B6E48B90019ED53 /* SocketTestCases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */; };
|
||||||
|
94CB8F0D1B6E66E60019ED53 /* AbstractSocketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -64,7 +83,6 @@
|
|||||||
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = "<group>"; };
|
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = "<group>"; };
|
||||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
572EF22A1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
572EF22A1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
572EF22B1B51F16C00EEBB58 /* SocketIO_iOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketIO_iOSTests.swift; sourceTree = "<group>"; };
|
|
||||||
572EF2381B51F18A00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
572EF2381B51F18A00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-Mac.h"; sourceTree = "<group>"; };
|
572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-Mac.h"; sourceTree = "<group>"; };
|
||||||
@ -84,6 +102,13 @@
|
|||||||
5764DF861B51F254004FF46E /* SocketTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketTypes.swift; path = SocketIOClientSwift/SocketTypes.swift; sourceTree = "<group>"; };
|
5764DF861B51F254004FF46E /* SocketTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketTypes.swift; path = SocketIOClientSwift/SocketTypes.swift; sourceTree = "<group>"; };
|
||||||
5764DF871B51F254004FF46E /* SwiftRegex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftRegex.swift; path = SocketIOClientSwift/SwiftRegex.swift; sourceTree = "<group>"; };
|
5764DF871B51F254004FF46E /* SwiftRegex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftRegex.swift; path = SocketIOClientSwift/SwiftRegex.swift; sourceTree = "<group>"; };
|
||||||
5764DF881B51F254004FF46E /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = SocketIOClientSwift/WebSocket.swift; sourceTree = "<group>"; };
|
5764DF881B51F254004FF46E /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = SocketIOClientSwift/WebSocket.swift; sourceTree = "<group>"; };
|
||||||
|
941A4AB91B67A56C00C42318 /* TestKind.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestKind.swift; sourceTree = "<group>"; };
|
||||||
|
94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespaceAcknowledgementTest.swift; sourceTree = "<group>"; };
|
||||||
|
945B65421B63D9DB0081E995 /* SocketEmitTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketEmitTest.swift; sourceTree = "<group>"; };
|
||||||
|
94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespaceEmitTest.swift; sourceTree = "<group>"; };
|
||||||
|
94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketAcknowledgementTest.swift; sourceTree = "<group>"; };
|
||||||
|
94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketTestCases.swift; sourceTree = "<group>"; };
|
||||||
|
94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AbstractSocketTest.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -163,7 +188,13 @@
|
|||||||
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
572EF22B1B51F16C00EEBB58 /* SocketIO_iOSTests.swift */,
|
945B65421B63D9DB0081E995 /* SocketEmitTest.swift */,
|
||||||
|
94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */,
|
||||||
|
94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */,
|
||||||
|
94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */,
|
||||||
|
941A4AB91B67A56C00C42318 /* TestKind.swift */,
|
||||||
|
94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */,
|
||||||
|
94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */,
|
||||||
572EF2291B51F16C00EEBB58 /* Supporting Files */,
|
572EF2291B51F16C00EEBB58 /* Supporting Files */,
|
||||||
);
|
);
|
||||||
path = "SocketIO-iOSTests";
|
path = "SocketIO-iOSTests";
|
||||||
@ -424,7 +455,26 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
572EF22C1B51F16C00EEBB58 /* SocketIO_iOSTests.swift in Sources */,
|
945B653E1B5FCEEA0081E995 /* SocketParser.swift in Sources */,
|
||||||
|
945B653D1B5FCEEA0081E995 /* SocketPacket.swift in Sources */,
|
||||||
|
945B653A1B5FCEEA0081E995 /* SocketFixUTF8.swift in Sources */,
|
||||||
|
945B65391B5FCEEA0081E995 /* SocketEventHandler.swift in Sources */,
|
||||||
|
94CB8F0B1B6E48B90019ED53 /* SocketTestCases.swift in Sources */,
|
||||||
|
945B65371B5FCEEA0081E995 /* SocketEngine.swift in Sources */,
|
||||||
|
945B65351B5FCEEA0081E995 /* SocketAckManager.swift in Sources */,
|
||||||
|
941A4ABA1B67A56C00C42318 /* TestKind.swift in Sources */,
|
||||||
|
94CB8F0D1B6E66E60019ED53 /* AbstractSocketTest.swift in Sources */,
|
||||||
|
945B65431B63D9DB0081E995 /* SocketEmitTest.swift in Sources */,
|
||||||
|
945B65401B5FCEEA0081E995 /* SwiftRegex.swift in Sources */,
|
||||||
|
945B653C1B5FCEEA0081E995 /* SocketLogger.swift in Sources */,
|
||||||
|
945B65381B5FCEEA0081E995 /* SocketEngineClient.swift in Sources */,
|
||||||
|
945B65361B5FCEEA0081E995 /* SocketAnyEvent.swift in Sources */,
|
||||||
|
94ADAC4B1B6632DD00FD79AE /* SocketAcknowledgementTest.swift in Sources */,
|
||||||
|
945B653F1B5FCEEA0081E995 /* SocketTypes.swift in Sources */,
|
||||||
|
945B653B1B5FCEEA0081E995 /* SocketIOClient.swift in Sources */,
|
||||||
|
94ADAC491B652D3300FD79AE /* SocketNamespaceEmitTest.swift in Sources */,
|
||||||
|
945B65411B5FCEEA0081E995 /* WebSocket.swift in Sources */,
|
||||||
|
94242BB81B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -37,10 +37,11 @@
|
|||||||
</BuildActionEntries>
|
</BuildActionEntries>
|
||||||
</BuildAction>
|
</BuildAction>
|
||||||
<TestAction
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
buildConfiguration = "Debug">
|
codeCoverageEnabled = "YES">
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
skipped = "NO">
|
skipped = "NO">
|
||||||
@ -62,15 +63,18 @@
|
|||||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</MacroExpansion>
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
buildConfiguration = "Debug"
|
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
allowLocationSimulation = "YES">
|
allowLocationSimulation = "YES">
|
||||||
<MacroExpansion>
|
<MacroExpansion>
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
@ -85,10 +89,10 @@
|
|||||||
</AdditionalOptions>
|
</AdditionalOptions>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
savedToolIdentifier = ""
|
savedToolIdentifier = ""
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
buildConfiguration = "Release"
|
|
||||||
debugDocumentVersioning = "YES">
|
debugDocumentVersioning = "YES">
|
||||||
<MacroExpansion>
|
<MacroExpansion>
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
|
|||||||
95
Socket.IO-Test-Server/TestCases.js
Normal file
95
Socket.IO-Test-Server/TestCases.js
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
var assert = require("assert")
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
basicTest: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
|
||||||
|
},
|
||||||
|
returnData: []
|
||||||
|
},
|
||||||
|
testNull: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert(!inputData)
|
||||||
|
},
|
||||||
|
returnData: [null]
|
||||||
|
},
|
||||||
|
testBinary: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert.equal(inputData.toString(), "gakgakgak2")
|
||||||
|
},
|
||||||
|
returnData: [new Buffer("gakgakgak2", "utf-8")]
|
||||||
|
},
|
||||||
|
testArray: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert.equal(inputData.length, 2)
|
||||||
|
assert.equal(inputData[0], "test1")
|
||||||
|
assert.equal(inputData[1], "test2")
|
||||||
|
},
|
||||||
|
returnData: [["test3", "test4"]]
|
||||||
|
},
|
||||||
|
testString: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert.equal(inputData, "marco")
|
||||||
|
},
|
||||||
|
returnData: ["polo"]
|
||||||
|
},
|
||||||
|
testBool: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert(!inputData)
|
||||||
|
},
|
||||||
|
returnData: [true]
|
||||||
|
},
|
||||||
|
testInteger: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert.equal(inputData, 10)
|
||||||
|
},
|
||||||
|
returnData: [20]
|
||||||
|
},
|
||||||
|
testDouble: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert.equal(inputData, 1.1)
|
||||||
|
},
|
||||||
|
returnData: [1.2]
|
||||||
|
},
|
||||||
|
testJSON: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert.equal(inputData.name, "test")
|
||||||
|
assert.equal(inputData.nestedTest.test, "test")
|
||||||
|
assert.equal(inputData.testArray.length, 1)
|
||||||
|
},
|
||||||
|
returnData: [{testString: "test", testNumber: 15, nestedTest: {test: "test"}, testArray: [1, 1]}]
|
||||||
|
},
|
||||||
|
testJSONWithBuffer: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert.equal(inputData.name, "test")
|
||||||
|
assert.equal(inputData.nestedTest.test, "test")
|
||||||
|
assert.equal(inputData.testArray.length, 1)
|
||||||
|
},
|
||||||
|
returnData: [{testString: "test", testNumber: 15, nestedTest: {test: "test"}, testArray: [new Buffer("gakgakgak2", "utf-8"), 1]}]
|
||||||
|
},testUnicode: {
|
||||||
|
assert: function(inputData) {
|
||||||
|
assert.equal(inputData, "🚀")
|
||||||
|
},
|
||||||
|
returnData: ["🚄"]
|
||||||
|
},testMultipleItems: {
|
||||||
|
assert: function(array, object, number, string, bool) {
|
||||||
|
assert.equal(array.length, 2)
|
||||||
|
assert.equal(array[0], "test1")
|
||||||
|
assert.equal(array[1], "test2")
|
||||||
|
assert.equal(number, 15)
|
||||||
|
assert.equal(string, "marco")
|
||||||
|
assert.equal(bool, false)
|
||||||
|
},
|
||||||
|
returnData: [[1, 2], {test: "bob"}, 25, "polo", false]
|
||||||
|
},testMultipleItemsWithBuffer: {
|
||||||
|
assert: function(array, object, number, string, binary) {
|
||||||
|
assert.equal(array.length, 2)
|
||||||
|
assert.equal(array[0], "test1")
|
||||||
|
assert.equal(array[1], "test2")
|
||||||
|
assert.equal(number, 15)
|
||||||
|
assert.equal(string, "marco")
|
||||||
|
assert.equal(binary.toString(), "gakgakgak2")
|
||||||
|
},
|
||||||
|
returnData: [[1, 2], {test: "bob"}, 25, "polo", new Buffer("gakgakgak2")]
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Socket.IO-Test-Server/acknowledgementEvents.js
Normal file
10
Socket.IO-Test-Server/acknowledgementEvents.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
function socketCallback(testKey, socket, testCase) {
|
||||||
|
return function() {
|
||||||
|
testCase.assert.apply(undefined , arguments)
|
||||||
|
var emitArguments = testCase.returnData;
|
||||||
|
var ack = arguments[arguments.length - 1]
|
||||||
|
ack.apply(socket, emitArguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.socketCallback = socketCallback
|
||||||
20
Socket.IO-Test-Server/emitEvents.js
Normal file
20
Socket.IO-Test-Server/emitEvents.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
function socketCallback(testKey, socket, testCase) {
|
||||||
|
return function() {
|
||||||
|
testCase.assert.apply(undefined , arguments)
|
||||||
|
|
||||||
|
var emitArguments = addArrays([testKey + "EmitReturn"], testCase.returnData)
|
||||||
|
socket.emit.apply(socket, emitArguments)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addArrays(firstArray, secondArray) {
|
||||||
|
var length = secondArray.length
|
||||||
|
var i;
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
firstArray.push(secondArray[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
return firstArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.socketCallback = socketCallback
|
||||||
13
Socket.IO-Test-Server/main.js
Normal file
13
Socket.IO-Test-Server/main.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
var app = require('express')()
|
||||||
|
var server = app.listen(8080)
|
||||||
|
var io = require('socket.io')(server)
|
||||||
|
var acknowledgementsEvents = require("./acknowledgementEvents.js")
|
||||||
|
var emitEvents = require("./emitEvents.js")
|
||||||
|
var socketEventRegister = require("./socketEventRegister.js")
|
||||||
|
|
||||||
|
socketEventRegister.register(io, emitEvents.socketCallback, "Emit")
|
||||||
|
socketEventRegister.register(io, acknowledgementsEvents.socketCallback, "Acknowledgement")
|
||||||
|
|
||||||
|
var nsp = io.of("/swift")
|
||||||
|
socketEventRegister.register(nsp, emitEvents.socketCallback, "Emit")
|
||||||
|
socketEventRegister.register(nsp, acknowledgementsEvents.socketCallback, "Acknowledgement")
|
||||||
15
Socket.IO-Test-Server/package.json
Normal file
15
Socket.IO-Test-Server/package.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "socket.io-client-swift-test-server",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "A simple server to test aginst",
|
||||||
|
"main": "main.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Lukas Schmidt",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.13.1",
|
||||||
|
"socket.io": "^1.3.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Socket.IO-Test-Server/socketEventRegister.js
Normal file
13
Socket.IO-Test-Server/socketEventRegister.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
var testCases = require("./TestCases.js")
|
||||||
|
|
||||||
|
function registerSocketForEvents(ioSocket, socketCallback, testKind) {
|
||||||
|
ioSocket.on('connection', function(socket) {
|
||||||
|
var testCase;
|
||||||
|
for(testKey in testCases) {
|
||||||
|
testCase = testCases[testKey]
|
||||||
|
socket.on((testKey + testKind), socketCallback(testKey, socket, testCase))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.register = registerSocketForEvents
|
||||||
113
SocketIO-iOSTests/AbstractSocketTest.swift
Normal file
113
SocketIO-iOSTests/AbstractSocketTest.swift
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
//
|
||||||
|
// AbstractSocketTest.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Lukas Schmidt on 02.08.15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class AbstractSocketTest: XCTestCase {
|
||||||
|
static let TEST_TIMEOUT = 8.0
|
||||||
|
var socket:SocketIOClient!
|
||||||
|
var testKind:TestKind?
|
||||||
|
|
||||||
|
override func tearDown() {
|
||||||
|
super.tearDown()
|
||||||
|
socket.close(fast: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func openConnection() {
|
||||||
|
let expection = self.expectationWithDescription("connect")
|
||||||
|
socket.on("connect") {data, ack in
|
||||||
|
expection.fulfill()
|
||||||
|
}
|
||||||
|
socket.connect()
|
||||||
|
XCTAssertTrue(socket.connecting)
|
||||||
|
waitForExpectationsWithTimeout(AbstractSocketTest.TEST_TIMEOUT, handler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateTestName(rawTestName:String) ->String {
|
||||||
|
return rawTestName + testKind!.rawValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkConnectionStatus() {
|
||||||
|
XCTAssertTrue(socket.connected)
|
||||||
|
XCTAssertFalse(socket.connecting)
|
||||||
|
XCTAssertFalse(socket.reconnecting)
|
||||||
|
XCTAssertFalse(socket.closed)
|
||||||
|
XCTAssertFalse(socket.secure)
|
||||||
|
}
|
||||||
|
|
||||||
|
func socketMultipleEmit(testName:String, emitData:Array<AnyObject>, callback:NormalCallback){
|
||||||
|
let finalTestname = generateTestName(testName)
|
||||||
|
weak var expection = self.expectationWithDescription(finalTestname)
|
||||||
|
func didGetEmit(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
callback(result, ack)
|
||||||
|
if let expection = expection {
|
||||||
|
expection.fulfill()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.emit(finalTestname, withItems: emitData)
|
||||||
|
socket.on(finalTestname + "Return", callback: didGetEmit)
|
||||||
|
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func socketEmit(testName:String, emitData:AnyObject?, callback:NormalCallback){
|
||||||
|
let finalTestname = generateTestName(testName)
|
||||||
|
weak var expection = self.expectationWithDescription(finalTestname)
|
||||||
|
func didGetEmit(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
callback(result, ack)
|
||||||
|
if let expection = expection {
|
||||||
|
expection.fulfill()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.on(finalTestname + "Return", callback: didGetEmit)
|
||||||
|
if let emitData = emitData {
|
||||||
|
socket.emit(finalTestname, emitData)
|
||||||
|
} else {
|
||||||
|
socket.emit(finalTestname)
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func socketAcknwoledgeMultiple(testName:String, Data:Array<AnyObject>, callback:NormalCallback){
|
||||||
|
let finalTestname = generateTestName(testName)
|
||||||
|
weak var expection = self.expectationWithDescription(finalTestname)
|
||||||
|
func didGetResult(result:NSArray?) {
|
||||||
|
callback(result, nil)
|
||||||
|
if let expection = expection {
|
||||||
|
expection.fulfill()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.emitWithAck(finalTestname, withItems: Data)(timeoutAfter: 5, callback: didGetResult)
|
||||||
|
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func socketAcknwoledge(testName:String, Data:AnyObject?, callback:NormalCallback){
|
||||||
|
let finalTestname = generateTestName(testName)
|
||||||
|
weak var expection = self.expectationWithDescription(finalTestname)
|
||||||
|
func didGet(result:NSArray?) {
|
||||||
|
callback(result, nil)
|
||||||
|
if let expection = expection {
|
||||||
|
expection.fulfill()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var ack:OnAckCallback!
|
||||||
|
if let Data = Data {
|
||||||
|
ack = socket.emitWithAck(finalTestname, Data)
|
||||||
|
} else {
|
||||||
|
ack = socket.emitWithAck(finalTestname)
|
||||||
|
}
|
||||||
|
ack(timeoutAfter: 20, callback: didGet)
|
||||||
|
|
||||||
|
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
82
SocketIO-iOSTests/SocketAcknowledgementTest.swift
Normal file
82
SocketIO-iOSTests/SocketAcknowledgementTest.swift
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
//
|
||||||
|
// SocketAcknowledgementTest.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Lukas Schmidt on 27.07.15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class SocketAcknowledgementTest: AbstractSocketTest {
|
||||||
|
|
||||||
|
override func setUp() {
|
||||||
|
super.setUp()
|
||||||
|
testKind = TestKind.Acknowledgement
|
||||||
|
socket = SocketIOClient(socketURL: "127.0.0.1:8080", opts: [
|
||||||
|
"reconnects": true, // default true
|
||||||
|
"reconnectAttempts": -1, // default -1
|
||||||
|
"reconnectWait": 5, // default 10
|
||||||
|
"forcePolling": false,
|
||||||
|
"forceWebsockets": false,// default false
|
||||||
|
"path": ""])
|
||||||
|
openConnection()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testConnectionStatus() {
|
||||||
|
super.checkConnectionStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBasic() {
|
||||||
|
SocketTestCases.testBasic(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testNull() {
|
||||||
|
SocketTestCases.testNull(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBinary() {
|
||||||
|
SocketTestCases.testBinary(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testArray() {
|
||||||
|
SocketTestCases.testArray(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testString() {
|
||||||
|
SocketTestCases.testString(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBool() {
|
||||||
|
SocketTestCases.testBool(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInteger() {
|
||||||
|
SocketTestCases.testInteger(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testDouble() {
|
||||||
|
SocketTestCases.testDouble(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSON() {
|
||||||
|
SocketTestCases.testJSON(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSONWithBuffer() {
|
||||||
|
SocketTestCases.testJSONWithBuffer(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testUnicode() {
|
||||||
|
SocketTestCases.testUnicode(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleItems() {
|
||||||
|
SocketTestCases.testMultipleItems(socketAcknwoledgeMultiple)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleWithBuffer() {
|
||||||
|
SocketTestCases.testMultipleItemsWithBuffer(socketAcknwoledgeMultiple)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
88
SocketIO-iOSTests/SocketEmitTest.swift
Normal file
88
SocketIO-iOSTests/SocketEmitTest.swift
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
//
|
||||||
|
// ConvertedSocketTest.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Lukas Schmidt on 25.07.15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class SocketEmitTest: AbstractSocketTest {
|
||||||
|
override func setUp() {
|
||||||
|
super.setUp()
|
||||||
|
testKind = TestKind.Emit
|
||||||
|
socket = SocketIOClient(socketURL: "127.0.0.1:8080", opts: [
|
||||||
|
"reconnects": true, // default true
|
||||||
|
"reconnectAttempts": -1, // default -1
|
||||||
|
"reconnectWait": 5, // default 10
|
||||||
|
"forcePolling": false,
|
||||||
|
"forceWebsockets": false,// default false
|
||||||
|
"path": ""]
|
||||||
|
)
|
||||||
|
openConnection()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tearDown() {
|
||||||
|
socket.close(fast: false)
|
||||||
|
super.tearDown()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testConnectionStatus() {
|
||||||
|
super.checkConnectionStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBasic() {
|
||||||
|
SocketTestCases.testBasic(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testNull() {
|
||||||
|
SocketTestCases.testNull(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBinary() {
|
||||||
|
SocketTestCases.testBinary(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testArray() {
|
||||||
|
SocketTestCases.testArray(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testString() {
|
||||||
|
SocketTestCases.testString(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBool() {
|
||||||
|
SocketTestCases.testBool(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInteger() {
|
||||||
|
SocketTestCases.testInteger(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testDouble() {
|
||||||
|
SocketTestCases.testDouble(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSON() {
|
||||||
|
SocketTestCases.testJSON(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSONWithBuffer() {
|
||||||
|
SocketTestCases.testJSONWithBuffer(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testUnicode() {
|
||||||
|
SocketTestCases.testUnicode(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleItems() {
|
||||||
|
SocketTestCases.testMultipleItems(socketMultipleEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleWithBuffer() {
|
||||||
|
SocketTestCases.testMultipleItemsWithBuffer(socketMultipleEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,36 +0,0 @@
|
|||||||
//
|
|
||||||
// SocketIO_iOSTests.swift
|
|
||||||
// SocketIO-iOSTests
|
|
||||||
//
|
|
||||||
// Created by Nacho Soto on 7/11/15.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
import XCTest
|
|
||||||
|
|
||||||
class SocketIO_iOSTests: XCTestCase {
|
|
||||||
|
|
||||||
override func setUp() {
|
|
||||||
super.setUp()
|
|
||||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
|
||||||
}
|
|
||||||
|
|
||||||
override func tearDown() {
|
|
||||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
||||||
super.tearDown()
|
|
||||||
}
|
|
||||||
|
|
||||||
func testExample() {
|
|
||||||
// This is an example of a functional test case.
|
|
||||||
XCTAssert(true, "Pass")
|
|
||||||
}
|
|
||||||
|
|
||||||
func testPerformanceExample() {
|
|
||||||
// This is an example of a performance test case.
|
|
||||||
self.measureBlock() {
|
|
||||||
// Put the code you want to measure the time of here.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
82
SocketIO-iOSTests/SocketNamespaceAcknowledgementTest.swift
Normal file
82
SocketIO-iOSTests/SocketNamespaceAcknowledgementTest.swift
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
//
|
||||||
|
// SocketNamespaceAcknowledgementTest.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Lukas Schmidt on 28.07.15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class SocketNamespaceAcknowledgementTest: AbstractSocketTest {
|
||||||
|
|
||||||
|
override func setUp() {
|
||||||
|
super.setUp()
|
||||||
|
testKind = TestKind.Acknowledgement
|
||||||
|
socket = SocketIOClient(socketURL: "127.0.0.1:8080", opts: [
|
||||||
|
"reconnects": true, // default true
|
||||||
|
"reconnectAttempts": -1, // default -1
|
||||||
|
"reconnectWait": 5, // default 10
|
||||||
|
"forcePolling": false,
|
||||||
|
"forceWebsockets": false,// default false
|
||||||
|
"path": "",
|
||||||
|
"nsp": "/swift"])
|
||||||
|
openConnection()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testConnectionStatus() {
|
||||||
|
super.checkConnectionStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBasic() {
|
||||||
|
SocketTestCases.testBasic(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testNull() {
|
||||||
|
SocketTestCases.testNull(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBinary() {
|
||||||
|
SocketTestCases.testBinary(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testArray() {
|
||||||
|
SocketTestCases.testArray(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testString() {
|
||||||
|
SocketTestCases.testString(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBool() {
|
||||||
|
SocketTestCases.testBool(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInteger() {
|
||||||
|
SocketTestCases.testInteger(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testDouble() {
|
||||||
|
SocketTestCases.testDouble(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSON() {
|
||||||
|
SocketTestCases.testJSON(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSONWithBuffer() {
|
||||||
|
SocketTestCases.testJSONWithBuffer(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testUnicode() {
|
||||||
|
SocketTestCases.testUnicode(socketAcknwoledge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleItems() {
|
||||||
|
SocketTestCases.testMultipleItems(socketAcknwoledgeMultiple)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleWithBuffer() {
|
||||||
|
SocketTestCases.testMultipleItemsWithBuffer(socketAcknwoledgeMultiple)
|
||||||
|
}
|
||||||
|
}
|
||||||
83
SocketIO-iOSTests/SocketNamespaceEmitTest.swift
Normal file
83
SocketIO-iOSTests/SocketNamespaceEmitTest.swift
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
//
|
||||||
|
// SocketNamespaceEmitTest.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Lukas Schmidt on 26.07.15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class SocketNamespaceEmitTest: AbstractSocketTest {
|
||||||
|
|
||||||
|
override func setUp() {
|
||||||
|
super.setUp()
|
||||||
|
testKind = TestKind.Emit
|
||||||
|
socket = SocketIOClient(socketURL: "127.0.0.1:8080", opts: [
|
||||||
|
"reconnects": true, // default true
|
||||||
|
"reconnectAttempts": -1, // default -1
|
||||||
|
"reconnectWait": 5, // default 10
|
||||||
|
"forcePolling": false,
|
||||||
|
"forceWebsockets": false,// default false
|
||||||
|
"path": "",
|
||||||
|
"nsp": "/swift"])
|
||||||
|
openConnection()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testConnectionStatus() {
|
||||||
|
super.checkConnectionStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBasic() {
|
||||||
|
SocketTestCases.testBasic(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testNull() {
|
||||||
|
SocketTestCases.testNull(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBinary() {
|
||||||
|
SocketTestCases.testBinary(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testArray() {
|
||||||
|
SocketTestCases.testArray(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testString() {
|
||||||
|
SocketTestCases.testString(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBool() {
|
||||||
|
SocketTestCases.testBool(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInteger() {
|
||||||
|
SocketTestCases.testInteger(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testDouble() {
|
||||||
|
SocketTestCases.testDouble(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSON() {
|
||||||
|
SocketTestCases.testJSON(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSONWithBuffer() {
|
||||||
|
SocketTestCases.testJSONWithBuffer(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testUnicode() {
|
||||||
|
SocketTestCases.testUnicode(socketEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleItems() {
|
||||||
|
SocketTestCases.testMultipleItems(socketMultipleEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleWithBuffer() {
|
||||||
|
SocketTestCases.testMultipleItemsWithBuffer(socketMultipleEmit)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
246
SocketIO-iOSTests/SocketTestCases.swift
Normal file
246
SocketIO-iOSTests/SocketTestCases.swift
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
//
|
||||||
|
// SocketTestCases.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Lukas Schmidt on 02.08.15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class SocketTestCases: NSObject {
|
||||||
|
typealias SocketSendFunction = (testName:String, emitData:AnyObject?, callback:NormalCallback)->()
|
||||||
|
|
||||||
|
static func testBasic(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "basicTest"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
|
||||||
|
}
|
||||||
|
abstractSocketSend(testName: testName, emitData: nil, callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testNull(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testNull"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let _ = result?.firstObject as? NSNull {
|
||||||
|
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
XCTFail("Should have NSNull as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
abstractSocketSend(testName: testName, emitData: NSNull(), callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testBinary(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testBinary"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let data = result?.firstObject as? NSData {
|
||||||
|
let string = NSString(data: data, encoding: NSUTF8StringEncoding)!
|
||||||
|
XCTAssertEqual(string, "gakgakgak2")
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have NSData as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let data = NSString(string: "gakgakgak2").dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
abstractSocketSend(testName: testName, emitData: data, callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testArray(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testArray"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let array = result?.firstObject as? NSArray {
|
||||||
|
XCTAssertEqual(array.count, 2)
|
||||||
|
XCTAssertEqual(array.firstObject! as! String, "test3")
|
||||||
|
XCTAssertEqual(array.lastObject! as! String, "test4")
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have NSArray as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
abstractSocketSend(testName: testName, emitData: ["test1", "test2"], callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testString(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testString"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let string = result?.firstObject as? String {
|
||||||
|
XCTAssertEqual(string, "polo")
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have String as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
abstractSocketSend(testName: testName, emitData: "marco", callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testBool(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testBool"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let bool = result?.firstObject as? NSNumber {
|
||||||
|
XCTAssertTrue(bool.boolValue)
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have Boolean as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
abstractSocketSend(testName: testName, emitData: false, callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testInteger(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testInteger"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let integer = result?.firstObject as? Int {
|
||||||
|
XCTAssertEqual(integer, 20)
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have Integer as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
abstractSocketSend(testName: testName, emitData: 10, callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testDouble(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testDouble"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let double = result?.firstObject as? NSNumber {
|
||||||
|
XCTAssertEqual(double.floatValue, 1.2)
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have Double as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
abstractSocketSend(testName: testName, emitData: 1.1, callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testJSONWithBuffer(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testJSONWithBuffer"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let json = result?.firstObject as? NSDictionary {
|
||||||
|
XCTAssertEqual(json.valueForKey("testString")! as! String, "test")
|
||||||
|
XCTAssertEqual(json.valueForKey("testNumber")! as! Int, 15)
|
||||||
|
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).count, 2)
|
||||||
|
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).last! as! Int, 1)
|
||||||
|
let string = NSString(data: (json.valueForKey("testArray")! as! Array<AnyObject>).first! as! NSData, encoding: NSUTF8StringEncoding)!
|
||||||
|
XCTAssertEqual(string, "gakgakgak2")
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have NSDictionary as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let json = ["name": "test", "testArray": ["hallo"], "nestedTest": ["test": "test"], "number": 15]
|
||||||
|
|
||||||
|
abstractSocketSend(testName: testName, emitData: json, callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testJSON(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testJSON"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let json = result?.firstObject as? NSDictionary {
|
||||||
|
XCTAssertEqual(json.valueForKey("testString")! as! String, "test")
|
||||||
|
XCTAssertEqual(json.valueForKey("testNumber")! as! Int, 15)
|
||||||
|
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).count, 2)
|
||||||
|
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).first! as! Int, 1)
|
||||||
|
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).last! as! Int, 1)
|
||||||
|
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have NSDictionary as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let json = ["name": "test", "testArray": ["hallo"], "nestedTest": ["test": "test"], "number": 15]
|
||||||
|
|
||||||
|
abstractSocketSend(testName: testName, emitData: json, callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testUnicode(abstractSocketSend:SocketSendFunction) {
|
||||||
|
let testName = "testUnicode"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
if let unicode = result?.firstObject as? String {
|
||||||
|
XCTAssertEqual(unicode, "🚄")
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have String as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
abstractSocketSend(testName: testName, emitData: "🚀", callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testMultipleItemsWithBuffer(abstractSocketMultipleSend:(testName:String, emitData:Array<AnyObject>, callback:NormalCallback)->()) {
|
||||||
|
let testName = "testMultipleItemsWithBuffer"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
XCTAssertEqual(result!.count, 5)
|
||||||
|
if result!.count != 5 {
|
||||||
|
XCTFail("Fatal Fail. Lost some Data")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if let array = result?.firstObject as? Array<AnyObject> {
|
||||||
|
XCTAssertEqual(array.last! as! Int, 2)
|
||||||
|
XCTAssertEqual(array.first! as! Int, 1)
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have Array as result")
|
||||||
|
}
|
||||||
|
if let dict = result?[1] as? NSDictionary {
|
||||||
|
XCTAssertEqual(dict.valueForKey("test") as! String, "bob")
|
||||||
|
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have NSDictionary as result")
|
||||||
|
}
|
||||||
|
if let number = result?[2] as? Int {
|
||||||
|
XCTAssertEqual(number, 25)
|
||||||
|
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have Integer as result")
|
||||||
|
}
|
||||||
|
if let string = result?[3] as? String {
|
||||||
|
XCTAssertEqual(string, "polo")
|
||||||
|
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have Integer as result")
|
||||||
|
}
|
||||||
|
if let data = result?[4] as? NSData {
|
||||||
|
let string = NSString(data: data, encoding: NSUTF8StringEncoding)!
|
||||||
|
XCTAssertEqual(string, "gakgakgak2")
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have NSData as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let data = NSString(string: "gakgakgak2").dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
let emitArray = [["test1", "test2"], ["test": "test"], 15, "marco", data]
|
||||||
|
abstractSocketMultipleSend(testName: testName, emitData: emitArray, callback: didGetResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func testMultipleItems(abstractSocketMultipleSend:(testName:String, emitData:Array<AnyObject>, callback:NormalCallback)->()) {
|
||||||
|
let testName = "testMultipleItems"
|
||||||
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
|
XCTAssertEqual(result!.count, 5)
|
||||||
|
if result!.count != 5 {
|
||||||
|
XCTFail("Fatal Fail. Lost some Data")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if let array = result?.firstObject as? Array<AnyObject> {
|
||||||
|
XCTAssertEqual(array.last! as! Int, 2)
|
||||||
|
XCTAssertEqual(array.first! as! Int, 1)
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have Array as result")
|
||||||
|
}
|
||||||
|
if let dict = result?[1] as? NSDictionary {
|
||||||
|
XCTAssertEqual(dict.valueForKey("test") as! String, "bob")
|
||||||
|
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have NSDictionary as result")
|
||||||
|
}
|
||||||
|
if let number = result?[2] as? Int {
|
||||||
|
XCTAssertEqual(number, 25)
|
||||||
|
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have Integer as result")
|
||||||
|
}
|
||||||
|
if let string = result?[3] as? String {
|
||||||
|
XCTAssertEqual(string, "polo")
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have Integer as result")
|
||||||
|
}
|
||||||
|
if let bool = result?[4] as? NSNumber {
|
||||||
|
XCTAssertFalse(bool.boolValue)
|
||||||
|
}else {
|
||||||
|
XCTFail("Should have NSNumber as result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let emitArray = [["test1", "test2"], ["test": "test"], 15, "marco", false]
|
||||||
|
abstractSocketMultipleSend(testName: testName, emitData: emitArray, callback: didGetResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
13
SocketIO-iOSTests/TestKind.swift
Normal file
13
SocketIO-iOSTests/TestKind.swift
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
//
|
||||||
|
// TestKind.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Lukas Schmidt on 28.07.15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum TestKind: String {
|
||||||
|
case Emit, Acknowledgement
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user