mirror of
https://github.com/hyperoslo/Cache.git
synced 2026-04-07 19:17:36 +00:00
25 lines
743 B
Swift
25 lines
743 B
Swift
import Foundation
|
|
|
|
#if os(iOS) || os(tvOS)
|
|
import UIKit
|
|
#elseif os(OSX)
|
|
import AppKit
|
|
#endif
|
|
|
|
struct TestHelper {
|
|
static func data(_ length : Int) -> Data {
|
|
let buffer = [UInt8](repeating: 0, count: length)
|
|
return Data(buffer)
|
|
}
|
|
|
|
static func triggerApplicationEvents() {
|
|
#if os(iOS) || os(tvOS)
|
|
NotificationCenter.default.post(name: UIApplication.didEnterBackgroundNotification, object: nil)
|
|
NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil)
|
|
#elseif os(macOS)
|
|
NotificationCenter.default.post(name: NSApplication.willTerminateNotification, object: nil)
|
|
NotificationCenter.default.post(name: NSApplication.didResignActiveNotification, object: nil)
|
|
#endif
|
|
}
|
|
}
|