Skip to content

Commit

Permalink
Release 2.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hdrsl committed Aug 8, 2022
1 parent dcff9e8 commit 6bf9f11
Show file tree
Hide file tree
Showing 31 changed files with 274 additions and 527 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ xcuserdata/
*.dSYM

# CocoaPods - Refactored to standalone file

Pods/*

# Carthage - Refactored to standalone file
Expand Down Expand Up @@ -155,3 +156,4 @@ tags
BluetoothMesh/docs/
ios_application/
ios/
MockingbirdMocks/
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "SILCharacteristicFieldValueResolver.h"
#import "SILBluetoothFieldModel.h"

@interface SILCharacteristicFieldValueResolver()
- (SInt64)sintCasterForSint:(SInt64)result originalSize:(int)originalSize castSize:(int)castSize;
@end

@interface SILCharacteristicFieldValueResolver(TestPrivate)
- (NSData*)dataForValueString:(NSString *)dataString asFormat:(NSString *)format;
- (NSString*)readValueString:(NSData *)data forFormat:(NSString *)format;
- (NSData*)dataForHexString:(NSString *)dataString;
@end

@interface SILValueResolverTests : XCTestCase
@end

Expand Down Expand Up @@ -50,17 +57,29 @@ @interface SILValueResolverTests : XCTestCase
NSString * const kRegCertFormat = @"reg-cert-data-list";
NSString * const kVariableFormat = @"variable";

@implementation SILValueResolverTests
SILBluetoothFieldModel* (^fieldForFormat)(NSString *format) = ^(NSString *format){
return [[SILBluetoothFieldModel alloc] initWithName:@"x" unit:@"unit" format:format requires:@"x"];
};

@implementation SILCharacteristicFieldValueResolver(TestPrivate)

- (void)setUp {
[super setUp];
- (NSData*)dataForValueString:(NSString *)dataString asFormat:(NSString *)format{
NSError *error;
return [self dataForValueString:dataString withFieldModel:fieldForFormat(format) error:&error];
}

- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
- (NSString*)readValueString:(NSData *)data forFormat:(NSString *)format{
return [self readValueString:data withFieldModel:fieldForFormat(format)];
}

- (NSData*)dataForHexString:(NSString *)dataString {
return [self dataForValueString:dataString asFormat:kVariableFormat];
}

@end

@implementation SILValueResolverTests

#pragma mark - NSData Bug

- (void)testGetBytesSuccess {
Expand Down Expand Up @@ -307,7 +326,7 @@ - (void)testUint64 {
}

- (void)testWriteUint64 {
uint64_t target = 13235973595268495360;
uint64_t target = 13235973595268495360ULL;
uint64_t written = 0;

NSData *writtenData = [[SILCharacteristicFieldValueResolver sharedResolver] dataForValueString:@"13235973595268495360" asFormat:kU64Format];
Expand Down Expand Up @@ -733,7 +752,7 @@ - (void)testWriteUtf16 {
#pragma mark - Hex String encoding

- (void)testDataForHexSuccess {
NSString *hexString = @"3A:55:0F:1B:4C";
NSString *hexString = @"3A550F1B4C";
const char target[5] = {0x3a, 0x55, 0x0f, 0x1B, 0x4c};
NSData *targetData = [NSData dataWithBytes:target length:sizeof(target)];

Expand All @@ -744,14 +763,7 @@ - (void)testDataForHexSuccess {
}

- (void)testDataForHexFailure_BadPair {
NSString *hexString = @"3T:55:0f:1B:4c";
NSData *stringData = [[SILCharacteristicFieldValueResolver sharedResolver] dataForHexString:hexString];

XCTAssertNil(stringData);
}

- (void)testDataForHexFailure_LongPair {
NSString *hexString = @"365:55:0f:1B:4c";
NSString *hexString = @"3T550f1B4c";
NSData *stringData = [[SILCharacteristicFieldValueResolver sharedResolver] dataForHexString:hexString];

XCTAssertNil(stringData);
Expand Down
22 changes: 11 additions & 11 deletions BlueGeckoTests/Matchers/SILGattConfigurationModelMatchers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ public func hasTheSameBluetoothFields<T: SILGattConfigurationCharacteristicEntit
case (let expected?, let actual?):
var matches = expected.name == actual.name
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic name: \(expected.name ?? "")", "characteristic name: \(actual.name ?? "")"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic name: \(expected.name ?? "")", actual: "characteristic name: \(actual.name ?? "")"))
}
matches = matches && expected.cbuuidString == actual.cbuuidString
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic cbuuidString: \(expected.cbuuidString)", "characteristic cbuuidString: \(actual.cbuuidString)"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic cbuuidString: \(expected.cbuuidString)", actual: "characteristic cbuuidString: \(actual.cbuuidString)"))
}
matches = matches && expected.properties.count == actual.properties.count
for property in expected.properties {
matches = matches && actual.properties.contains(property)
}
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic properties: \(expected.properties)", "characteristic properties: \(actual.properties)"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic properties: \(expected.properties)", actual: "characteristic properties: \(actual.properties)"))
}
matches = matches && expected.initialValueType == actual.initialValueType
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic initial value type: \(expected.initialValueType)", "characteristic initial value type: \(actual.initialValueType)"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic initial value type: \(expected.initialValueType)", actual: "characteristic initial value type: \(actual.initialValueType)"))
}
matches = matches && expected.initialValue == actual.initialValue
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic initial value: \(expected.initialValue ?? "")", "characteristic initial value: \(actual.initialValue ?? "")"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("characteristic initial value: \(expected.initialValue ?? "")", actual: "characteristic initial value: \(actual.initialValue ?? "")"))
}
matches = matches && expected.descriptors.count == actual.descriptors.count
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptors number \(expected.descriptors.count)", "descriptors number \(actual.descriptors.count)"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptors number \(expected.descriptors.count)", actual: "descriptors number \(actual.descriptors.count)"))
}
return PredicateResult(bool: matches, message: msg)
}
Expand All @@ -63,26 +63,26 @@ public func hasTheSameBluetoothFields<T: SILGattConfigurationDescriptorEntity> (
case (let expected?, let actual?):
var matches = expected.name == actual.name
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor name: \(expected.name ?? "")", "descriptor name: \(actual.name ?? "")"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor name: \(expected.name ?? "")", actual: "descriptor name: \(actual.name ?? "")"))
}
matches = matches && expected.cbuuidString == actual.cbuuidString
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor cbuuidString: \(expected.cbuuidString)", "descriptor cbuuidString: \(actual.cbuuidString)"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor cbuuidString: \(expected.cbuuidString)", actual: "descriptor cbuuidString: \(actual.cbuuidString)"))
}
matches = matches && expected.properties.count == actual.properties.count
for property in expected.properties {
matches = matches && actual.properties.contains(property)
}
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor properties: \(expected.properties)", "descriptor properties: \(actual.properties)"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor properties: \(expected.properties)", actual: "descriptor properties: \(actual.properties)"))
}
matches = matches && expected.initialValueType == actual.initialValueType
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor initial value type: \(expected.initialValueType)", "descriptor initial value type: \(actual.initialValueType)"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor initial value type: \(expected.initialValueType)", actual: "descriptor initial value type: \(actual.initialValueType)"))
}
matches = matches && expected.initialValue == actual.initialValue
if !matches {
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor initial value: \(expected.initialValue ?? "")", "descriptor initial value: \(actual.initialValue ?? "")"))
return PredicateResult(bool: false, message: ExpectationMessage.expectedCustomValueTo("descriptor initial value: \(expected.initialValue ?? "")", actual: "descriptor initial value: \(actual.initialValue ?? "")"))
}
return PredicateResult(bool: matches, message: msg)
}
Expand Down
7 changes: 7 additions & 0 deletions MockingbirdSupport/AppKit/NSResponder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import AppKit
import Foundation

open class NSResponder : NSObject, NSCoding {
public init()
public required init?(coder: NSCoder)
}
7 changes: 7 additions & 0 deletions MockingbirdSupport/AppKit/NSView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import AppKit
import Foundation

open class NSView : NSResponder {
public init(frame frameRect: NSRect)
public required init?(coder: NSCoder)
}
8 changes: 8 additions & 0 deletions MockingbirdSupport/AppKit/NSViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import AppKit
import Foundation

@available(OSX 10.5, *)
open class NSViewController : NSResponder {
public init(nibName nibNameOrNil: NSNib.Name?, bundle nibBundleOrNil: Bundle?)
public required init?(coder: NSCoder)
}
20 changes: 20 additions & 0 deletions MockingbirdSupport/Foundation/ObjectiveC/NSObject.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import ObjectiveC

public protocol NSObjectProtocol {}

open class NSObject : NSObjectProtocol {
public init() {}
}

public protocol NSCopying {
func copy(with zone: NSZone?) -> Any
}

public protocol NSMutableCopying {
func mutableCopy(with zone: NSZone?) -> Any
}

public protocol NSCoding {
func encode(with coder: NSCoder)
init?(coder: NSCoder)
}
21 changes: 21 additions & 0 deletions MockingbirdSupport/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Bird Rides, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions MockingbirdSupport/Swift/Codable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public protocol Encodable {
func encode(to encoder: Encoder) throws
}

public protocol Decodable {
@objc(mkb_implicit) init(from decoder: Decoder) throws
}

public typealias Codable = Decodable & Encodable
6 changes: 6 additions & 0 deletions MockingbirdSupport/Swift/Comparable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public protocol Comparable : Equatable {
static func < (lhs: Self, rhs: Self) -> Bool
static func <= (lhs: Self, rhs: Self) -> Bool
static func >= (lhs: Self, rhs: Self) -> Bool
static func > (lhs: Self, rhs: Self) -> Bool
}
3 changes: 3 additions & 0 deletions MockingbirdSupport/Swift/Equatable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public protocol Equatable {
static func == (lhs: Self, rhs: Self) -> Bool
}
4 changes: 4 additions & 0 deletions MockingbirdSupport/Swift/Hashable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public protocol Hashable : Equatable {
var hashValue: Int { get }
func hash(into hasher: inout Hasher)
}
13 changes: 13 additions & 0 deletions MockingbirdSupport/Swift/Misc.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public protocol AnyObject {}

public typealias `class` = AnyObject

public typealias AnyClass = AnyObject.Type

public protocol CustomStringConvertible {
var description: String { get }
}

public protocol CustomDebugStringConvertible {
var debugDescription: String { get }
}
5 changes: 5 additions & 0 deletions MockingbirdSupport/UIKit/UIControl.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation
import UIKit

@available(iOS 2.0, *)
open class UIControl : UIView {}
5 changes: 5 additions & 0 deletions MockingbirdSupport/UIKit/UILabel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation
import UIKit

@available(iOS 2.0, *)
open class UILabel : UIView, NSCoding {}
8 changes: 8 additions & 0 deletions MockingbirdSupport/UIKit/UIView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation
import UIKit

@available(iOS 2.0, *)
open class UIView : NSCoding {
public init(frame: CGRect)
public required init?(coder: NSCoder)
}
8 changes: 8 additions & 0 deletions MockingbirdSupport/UIKit/UIViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation
import UIKit

@available(iOS 2.0, *)
open class UIViewController : UIResponder, NSCoding {
public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?)
public required init?(coder: NSCoder)
}
6 changes: 1 addition & 5 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_pods
pod 'Quick'
pod 'Nimble'
pod 'OCMock'
pod 'MockingbirdFramework', '~> 0.20'
end

target 'BlueGecko' do
Expand All @@ -45,11 +46,6 @@ target 'WirelessGecko' do
shared_pods
end

target 'SiliconLabsAppTests' do
shared_pods
test_pods
end

target 'BlueGeckoTests' do
shared_pods
test_pods
Expand Down

0 comments on commit 6bf9f11

Please sign in to comment.