From c0b25d9cef372999977053f9047ab56bf1c3dc4b Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Fri, 22 Apr 2016 19:33:14 +0100 Subject: [PATCH] RTN15c4 (#401) * RTN15c4 * RTN15c4: pending --- Spec/RealtimeClientConnection.swift | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Spec/RealtimeClientConnection.swift b/Spec/RealtimeClientConnection.swift index e5d4b1f5b..9266d3411 100644 --- a/Spec/RealtimeClientConnection.swift +++ b/Spec/RealtimeClientConnection.swift @@ -1546,6 +1546,37 @@ class RealtimeClientConnection: QuickSpec { expect(client.msgSerial).to(equal(0)) } + // RTN15c4 + pending("ERROR ProtocolMessage indicating a fatal error in the connection") { + let options = AblyTests.commonAppSetup() + options.disconnectedRetryTimeout = 1.0 + let client = AblyTests.newRealtime(options) + defer { client.close() } + let channel = client.channels.get("test") + + expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.Connected), timeout: testTimeout) + + client.onDisconnected() + + let protocolError = AblyTests.newErrorProtocolMessage() + client.connection.once(.Connecting) { _ in + // Resuming + let transport = client.transport as! TestProxyTransport + transport.actionsIgnored += [.Connected] + client.onError(protocolError) + } + + waitUntil(timeout: testTimeout) { done in + client.connection.once(.Failed) { stateChange in + expect(stateChange!.reason).to(beIdenticalTo(protocolError.error)) + expect(client.connection.errorReason).to(beIdenticalTo(protocolError.error)) + done() + } + } + expect(channel.state).to(equal(ARTRealtimeChannelState.Failed)) + expect(channel.errorReason).to(beIdenticalTo(protocolError.error)) + } + } // RTN15d