Skip to content

Commit

Permalink
RTN20a: pending (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira authored and tcard committed May 2, 2016
1 parent 00ded91 commit 8b899a2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Spec/RealtimeClientConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,38 @@ class RealtimeClientConnection: QuickSpec {

}

// RTN20
context("Operating System events for network/internet connectivity changes") {

// RTN20a
pending("should immediately change the state to DISCONNECTED if the operating system indicates that the underlying internet connection is no longer available") {
let options = AblyTests.commonAppSetup()
options.disconnectedRetryTimeout = 0.5
let client = ARTRealtime(options: options)
defer { client.close() }
waitUntil(timeout: testTimeout) { done in
client.connection.once(.Connecting) { stateChange in
expect(stateChange!.reason).to(beNil())
client.simulateOSEventNoInternetConnection()
done()
}
}
waitUntil(timeout: testTimeout) { done in
client.connection.once(.Connected) { stateChange in
client.simulateOSEventNoInternetConnection()
done()
}
}
waitUntil(timeout: testTimeout) { done in
client.connection.once(.Connecting) { stateChange in
expect(stateChange!.reason).toNot(beNil())
done()
}
}
}

}

}
}
}
7 changes: 7 additions & 0 deletions Spec/TestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,13 @@ extension ARTRealtime {
}
}

func simulateOSEventNoInternetConnection() {
// TODO
// It depends on how the SystemConfiguration Reachablity APIs is used.
// Basic demonstration: https://developer.apple.com/library/ios/samplecode/Reachability/Introduction/Intro.html
self.onDisconnected()
}

func dispose() {
let names = self.channels.map({ $0.name })
for name in names {
Expand Down

0 comments on commit 8b899a2

Please sign in to comment.