Skip to content

Commit 37ea60f

Browse files
Merge pull request #160 from apple/swift-3-darwin-parity-runloop-notification
React to changes coming in swift-corelibs-foundation
2 parents 40e532c + 0e1c25e commit 37ea60f

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Sources/XCTest/Public/XCTestCase+Asynchronous.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public extension XCTestCase {
103103
// been fulfilled, it would be more efficient to use a runloop
104104
// source that can be signaled to wake up when an expectation is
105105
// fulfilled.
106-
let runLoop = RunLoop.current()
106+
let runLoop = RunLoop.current
107107
let timeoutDate = Date(timeIntervalSinceNow: timeout)
108108
repeat {
109109
unfulfilledDescriptions = []
@@ -171,14 +171,14 @@ public extension XCTestCase {
171171
var observer: NSObjectProtocol? = nil
172172
func removeObserver() {
173173
if let observer = observer as? AnyObject {
174-
NotificationCenter.defaultCenter().removeObserver(observer)
174+
NotificationCenter.default.removeObserver(observer)
175175
}
176176
}
177177

178178
weak var weakExpectation = expectation
179179
observer = NotificationCenter
180-
.defaultCenter()
181-
.addObserverForName(Notification.Name(rawValue: notificationName),
180+
.default
181+
.addObserver(forName: Notification.Name(rawValue: notificationName),
182182
object: objectToObserve,
183183
queue: nil,
184184
usingBlock: {

Tests/Functional/Asynchronous/Notifications/Expectations/main.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class NotificationExpectationsTestCase: XCTestCase {
2121
func test_observeNotificationWithName_passes() {
2222
let notificationName = "notificationWithNameTest"
2323
expectation(forNotification: notificationName, object:nil)
24-
NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: notificationName), object: nil)
24+
NotificationCenter.default.postNotificationName(Notification.Name(rawValue: notificationName), object: nil)
2525
waitForExpectations(timeout: 0.0)
2626
}
2727

@@ -31,7 +31,7 @@ class NotificationExpectationsTestCase: XCTestCase {
3131
let notificationName = "notificationWithNameAndObjectTest"
3232
let dummyObject = NSObject()
3333
expectation(forNotification: notificationName, object:dummyObject)
34-
NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: notificationName), object: dummyObject)
34+
NotificationCenter.default.postNotificationName(Notification.Name(rawValue: notificationName), object: dummyObject)
3535
waitForExpectations(timeout: 0.0)
3636
}
3737

@@ -41,7 +41,7 @@ class NotificationExpectationsTestCase: XCTestCase {
4141
let notificationName = "notificationWithNameAndObject_expectNoObjectTest"
4242
expectation(forNotification: notificationName, object:nil)
4343
let dummyObject = NSObject()
44-
NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: notificationName), object: dummyObject)
44+
NotificationCenter.default.postNotificationName(Notification.Name(rawValue: notificationName), object: dummyObject)
4545
waitForExpectations(timeout: 0.0)
4646
}
4747

@@ -50,7 +50,7 @@ class NotificationExpectationsTestCase: XCTestCase {
5050
// CHECK: Test Case 'NotificationExpectationsTestCase.test_observeNotificationWithIncorrectName_fails' failed \(\d+\.\d+ seconds\).
5151
func test_observeNotificationWithIncorrectName_fails() {
5252
expectation(forNotification: "expectedName", object: nil)
53-
NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: "actualName"), object: nil)
53+
NotificationCenter.default.postNotificationName(Notification.Name(rawValue: "actualName"), object: nil)
5454
waitForExpectations(timeout: 0.1)
5555
}
5656

@@ -62,7 +62,7 @@ class NotificationExpectationsTestCase: XCTestCase {
6262
let dummyObject: NSString = "dummyObject"
6363
let anotherDummyObject = NSObject()
6464
expectation(forNotification: notificationName, object: dummyObject)
65-
NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: notificationName), object:anotherDummyObject)
65+
NotificationCenter.default.postNotificationName(Notification.Name(rawValue: notificationName), object:anotherDummyObject)
6666
waitForExpectations(timeout: 0.1)
6767
}
6868

Tests/Functional/Asynchronous/Notifications/Handler/main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NotificationHandlerTestCase: XCTestCase {
2323
notification in
2424
return false
2525
})
26-
NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: "returnFalse"), object: nil)
26+
NotificationCenter.default.postNotificationName(Notification.Name(rawValue: "returnFalse"), object: nil)
2727
waitForExpectations(timeout: 0.1)
2828
}
2929

@@ -34,7 +34,7 @@ class NotificationHandlerTestCase: XCTestCase {
3434
notification in
3535
return true
3636
})
37-
NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: "returnTrue"), object: nil)
37+
NotificationCenter.default.postNotificationName(Notification.Name(rawValue: "returnTrue"), object: nil)
3838
waitForExpectations(timeout: 0.1)
3939
}
4040

@@ -47,7 +47,7 @@ class NotificationHandlerTestCase: XCTestCase {
4747
return true
4848
})
4949
waitForExpectations(timeout: 0.1, handler: nil)
50-
NotificationCenter.defaultCenter().postNotificationName(Notification.Name(rawValue: "note"), object: nil)
50+
NotificationCenter.default.postNotificationName(Notification.Name(rawValue: "note"), object: nil)
5151
}
5252

5353
static var allTests = {

0 commit comments

Comments
 (0)