Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RTP3 for 0.9 #566

Merged
merged 1 commit into from
Jan 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions Spec/RealtimeClientPresence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class RealtimeClientPresence: QuickSpec {
let options = AblyTests.commonAppSetup()
options.disconnectedRetryTimeout = 1.0
var clientSecondary: ARTRealtime!
defer { clientSecondary.close() }
defer { clientSecondary.dispose(); clientSecondary.close() }

waitUntil(timeout: testTimeout) { done in
clientSecondary = AblyTests.addMembersSequentiallyToChannel("test", members: 150, options: options) {
Expand All @@ -100,7 +100,9 @@ class RealtimeClientPresence: QuickSpec {
var lastSyncSerial: String?
waitUntil(timeout: testTimeout) { done in
channel.attach() { _ in
let transport = client.transport as! TestProxyTransport
guard let transport = client.transport as? TestProxyTransport else {
fail("TestProxyTransport is not set"); return
}
transport.afterProcessingReceivedMessage = { protocolMessage in
if protocolMessage.action == .Sync {
lastSyncSerial = protocolMessage.channelSerial
Expand All @@ -111,15 +113,33 @@ class RealtimeClientPresence: QuickSpec {
}
}

expect(channel.presenceMap.members).toNot(haveCount(150))
expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.Connecting), timeout: options.disconnectedRetryTimeout + 1.0)
expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.Connected), timeout: testTimeout)

//Client library requests a SYNC resume by sending a SYNC ProtocolMessage with the last received sync serial number
let transport = client.transport as! TestProxyTransport
expect(transport.protocolMessagesSent.filter{ $0.action == .Sync }).toEventually(haveCount(1), timeout: testTimeout)
expect(transport.protocolMessagesSent.filter{ $0.action == .Sync }.first!.channelSerial).to(equal(lastSyncSerial))
// Client library requests a SYNC resume by sending a SYNC ProtocolMessage with the last received sync serial number
guard let transport = client.transport as? TestProxyTransport else {
fail("TestProxyTransport is not set"); return
}

let syncSentProtocolMessages = transport.protocolMessagesSent.filter({ $0.action == .Sync })
guard let syncSentMessage = syncSentProtocolMessages.last where syncSentProtocolMessages.count == 1 else {
fail("Should send one SYNC protocol message"); return
}
expect(syncSentMessage.channelSerial).to(equal(lastSyncSerial))

expect(transport.protocolMessagesReceived.filter{ $0.action == .Sync }).toEventually(haveCount(2), timeout: testTimeout)

waitUntil(timeout: testTimeout) { done in
channel.presence.get { members, error in
expect(error).to(beNil())
guard let members = members else {
fail("No present members"); done(); return
}
expect(members).to(haveCount(150))
done()
}
}
}

// RTP4
Expand Down