Skip to content

Commit

Permalink
RTN14e (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira authored and tcard committed Apr 29, 2016
1 parent 743c1e1 commit 5eeae37
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Spec/RealtimeClientConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,41 @@ class RealtimeClientConnection: QuickSpec {
expect(totalRetry).to(equal(Int(expectedTime / options.disconnectedRetryTimeout)))
}

// RTN14e
it("connection state has been in the DISCONNECTED state for more than the default connectionStateTtl should change the state to SUSPENDED") {
let options = AblyTests.commonAppSetup()
options.realtimeHost = "10.255.255.1" //non-routable IP address
options.disconnectedRetryTimeout = 0.1
options.suspendedRetryTimeout = 0.5
options.autoConnect = false
let expectedTime = 1.0

let previousConnectionStateTtl = ARTDefault.connectionStateTtl()
defer { ARTDefault.setConnectionStateTtl(previousConnectionStateTtl) }
ARTDefault.setConnectionStateTtl(expectedTime)

let previousRealtimeRequestTimeout = ARTDefault.realtimeRequestTimeout()
defer { ARTDefault.setRealtimeRequestTimeout(previousRealtimeRequestTimeout) }
ARTDefault.setRealtimeRequestTimeout(0.1)

let client = ARTRealtime(options: options)
defer { client.close() }

waitUntil(timeout: testTimeout) { done in
client.connection.on(.Suspended) { stateChange in
expect(client.connection.errorReason!.message).to(contain("timed out"))

let start = NSDate()
client.connection.once(.Connecting) { stateChange in
let end = NSDate()
expect(end.timeIntervalSinceDate(start)).to(beCloseTo(options.suspendedRetryTimeout, within: 0.5))
done()
}
}
client.connect()
}
}

}

// RTN15
Expand Down

0 comments on commit 5eeae37

Please sign in to comment.