Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Aug 23, 2021
2 parents b23d88b + 1df87f6 commit 0a1a70f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CoreBluetoothMock/Classes/CBMCentralManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ open class CBMCentralManager: NSObject {
/// This method returns the value set as `CBMCentralManagerMock.simulateAuthorization`
/// or, if set to `nil`, the native result returned by `CBCentralManager`.
@available(iOS, introduced: 13.0, deprecated: 13.1)
@available(macOS, introduced: 10.15)
@available(tvOS, introduced: 13.0, deprecated: 13.1)
@available(watchOS, introduced: 6.0, deprecated: 6.1)
open var authorization: CBMManagerAuthorization {
if let rawValue = CBMCentralManagerMock.bluetoothAuthorization,
let authotization = CBMManagerAuthorization(rawValue: rawValue) {
Expand All @@ -112,7 +115,7 @@ open class CBMCentralManager: NSObject {
/// - Note:
/// This method returns the value set as `CBMCentralManagerMock.simulateAuthorization`
/// or, if set to `nil`, the native result returned by `CBCentralManager`.
@available(iOS 13.1, *)
@available(iOS 13.1, macOS 10.15, tvOS 13.1, watchOS 6.1, *)
open class var authorization: CBMManagerAuthorization {
if let rawValue = CBMCentralManagerMock.bluetoothAuthorization,
let authotization = CBMManagerAuthorization(rawValue: rawValue) {
Expand Down
15 changes: 10 additions & 5 deletions CoreBluetoothMock/Classes/CBMCentralManagerMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ open class CBMCentralManagerMock: CBMCentralManager {
/// Simulates the current authorization state of a Core Bluetooth manager.
///
/// When set to `nil` (default), the native value is returned.
@available(iOS 13.0, *)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public static func simulateAuthorization(_ authorization: CBMManagerAuthorization) {
bluetoothAuthorization = authorization.rawValue
}
Expand Down Expand Up @@ -457,6 +457,9 @@ open class CBMCentralManagerMock: CBMCentralManager {
}

@available(iOS, introduced: 13.0, deprecated: 13.1)
@available(macOS, introduced: 10.15)
@available(tvOS, introduced: 13.0, deprecated: 13.1)
@available(watchOS, introduced: 6.0, deprecated: 6.1)
open override var authorization: CBMManagerAuthorization {
if let rawValue = CBMCentralManagerMock.bluetoothAuthorization,
let authotization = CBMManagerAuthorization(rawValue: rawValue) {
Expand All @@ -467,7 +470,7 @@ open class CBMCentralManagerMock: CBMCentralManager {
}
}

@available(iOS 13.1, *)
@available(iOS 13.1, macOS 10.15, tvOS 13.1, watchOS 6.1, *)
open override class var authorization: CBMManagerAuthorization {
if let rawValue = CBMCentralManagerMock.bluetoothAuthorization,
let authotization = CBMManagerAuthorization(rawValue: rawValue) {
Expand Down Expand Up @@ -705,10 +708,12 @@ open class CBMCentralManagerMock: CBMCentralManager {
+ peripheralsConnectedByOtherApps
}

@available(iOS 13.0, *)
#if !os(macOS)
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
open override func registerForConnectionEvents(options: [CBMConnectionEventMatchingOption : Any]? = nil) {
fatalError("Mock connection events are not implemented")
}
#endif

fileprivate func ensurePoweredOn() -> Bool {
guard state == .poweredOn else {
Expand Down Expand Up @@ -736,7 +741,7 @@ open class CBMPeripheralMock: CBMPeer, CBMPeripheral {
/// Size of the outgoing buffer. Only this many packets
/// can be written without response in a loop, without
/// waiting for `canSendWriteWithoutResponse`.
private let bufferSize = 20
private let bufferSize = 20
/// The supervision timeout is a time after which a device realizes
/// that a connected peer has disconnected, had there been no signal
/// from it.
Expand All @@ -747,7 +752,7 @@ open class CBMPeripheralMock: CBMPeer, CBMPeripheral {

/// A flag set to <i>true</i> when the device was scanned
/// at least once.
fileprivate var wasScanned: Bool = false
fileprivate var wasScanned: Bool = false
/// A flag set to <i>true</i> when the device was connected
/// and iOS had chance to read device name.
fileprivate var wasConnected: Bool = false
Expand Down
5 changes: 4 additions & 1 deletion CoreBluetoothMock/Classes/CBMCentralManagerNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@ public class CBMCentralManagerNative: CBMCentralManager {
}

@available(iOS, introduced: 13.0, deprecated: 13.1)
@available(macOS, introduced: 10.15)
@available(tvOS, introduced: 13.0, deprecated: 13.1)
@available(watchOS, introduced: 6.0, deprecated: 6.1)
public override var authorization: CBMManagerAuthorization {
return manager.authorization
}

@available(iOS 13.1, *)
@available(iOS 13.1, macOS 10.15, tvOS 13.1, watchOS 6.1, *)
public override class var authorization: CBMManagerAuthorization {
return CBCentralManager.authorization
}
Expand Down

0 comments on commit 0a1a70f

Please sign in to comment.