Skip to content

Commit 80a9d3a

Browse files
committed
Merge branch 'swift5-tests-fix'
2 parents b1389a2 + 0ad1e38 commit 80a9d3a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

RxHttpClient/RequestPlugin/ActivityIndicatorPlugin.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public final class NetworkActivityIndicatorPlugin : RequestPluginType {
2121

2222
var counter = 0 {
2323
didSet {
24+
guard !Thread.isMainThread else {
25+
application.isNetworkActivityIndicatorVisible = counter != 0
26+
return
27+
}
28+
2429
DispatchQueue.main.async {
2530
self.application.isNetworkActivityIndicatorVisible = self.counter != 0
2631
}

RxHttpClientTests/Fake.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class FakeDataTask : NSObject, URLSessionDataTaskType {
3030

3131
open func cancel() {
3232
if !isCancelled {
33+
state = .suspended
34+
isCancelled = true
3335
cancelClosure?(self)
34-
state = .suspended
35-
isCancelled = true
3636
}
3737
}
3838
}

RxHttpClientTests/HttpClientBasicTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ class HttpClientBasicTests: XCTestCase {
2626
func testTerminateRequest() {
2727
let fakeSession = FakeSession()
2828
let cancelExpectation = expectation(description: "Should cancel task")
29+
cancelExpectation.assertForOverFulfill = false
2930
let resumeExpectation = expectation(description: "Should start task")
3031
fakeSession.task = FakeDataTask(resumeClosure: { _ in resumeExpectation.fulfill() }, cancelClosure: { _ in cancelExpectation.fulfill() })
3132
let client = HttpClient(session: fakeSession)
3233
let url = URL(baseUrl: "https://test.com/json", parameters: nil)!
34+
3335
let disposable = client.requestData(url: url)
3436
.do(
3537
onNext: { e in
3638
XCTFail("Should not receive responce")
3739
},
3840
onCompleted: { XCTFail("Should not complete task") })
3941
.subscribe()
40-
41-
XCTAssertEqual(false, fakeSession.task?.isCancelled)
42-
43-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { disposable.dispose() }
42+
43+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { disposable.dispose() }
4444

4545
let waitResult = XCTWaiter().wait(for: [resumeExpectation, cancelExpectation], timeout: waitTimeout, enforceOrder: true)
4646

0 commit comments

Comments
 (0)