Skip to content

Commit

Permalink
Adding Boris' test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
woody-apple committed Jul 2, 2022
1 parent fcbf745 commit bf26067
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIP/MTRDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ extern NSString * const MTRArrayValueType;
maxInterval:(uint16_t)maxInterval
params:(nullable MTRSubscribeParams *)params
cacheContainer:(MTRAttributeCacheContainer * _Nullable)attributeCacheContainer
attributeReportHandler:(void (^)(NSArray * value))attributeReportHandler
eventReportHandler:(void (^)(NSArray * value))eventReportHandler
attributeReportHandler:(nullable void (^)(NSArray * value))attributeReportHandler
eventReportHandler:(nullable void (^)(NSArray * value))eventReportHandler
errorHandler:(void (^)(NSError * error))errorHandler
subscriptionEstablished:(nullable void (^)(void))subscriptionEstablishedHandler;

Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ - (void)subscribeWithQueue:(dispatch_queue_t)queue
maxInterval:(uint16_t)maxInterval
params:(nullable MTRSubscribeParams *)params
cacheContainer:(MTRAttributeCacheContainer * _Nullable)attributeCacheContainer
attributeReportHandler:(void (^)(NSArray * value))attributeReportHandler
eventReportHandler:(void (^)(NSArray * value))eventReportHandler
attributeReportHandler:(nullable void (^)(NSArray * value))attributeReportHandler
eventReportHandler:(nullable void (^)(NSArray * value))eventReportHandler
errorHandler:(void (^)(NSError * error))errorHandler
subscriptionEstablished:(nullable void (^)(void))subscriptionEstablishedHandler
{
Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIP/MTRDeviceOverXPC.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ - (void)subscribeWithQueue:(dispatch_queue_t)queue
maxInterval:(uint16_t)maxInterval
params:(nullable MTRSubscribeParams *)params
cacheContainer:(MTRAttributeCacheContainer * _Nullable)attributeCacheContainer
attributeReportHandler:(void (^)(NSArray * value))attributeReportHandler
eventReportHandler:(void (^)(NSArray * value))eventReportHandler
attributeReportHandler:(nullable void (^)(NSArray * value))attributeReportHandler
eventReportHandler:(nullable void (^)(NSArray * value))eventReportHandler
errorHandler:(void (^)(NSError * error))errorHandler
subscriptionEstablished:(nullable void (^)(void))subscriptionEstablishedHandler;
{
Expand Down
11 changes: 11 additions & 0 deletions src/darwin/Framework/CHIPTests/MTRDeviceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -708,17 +708,28 @@ - (void)test011_ReadCachedAttribute
XCTestExpectation * subscribeExpectation = [self expectationWithDescription:@"Subscription complete"];

NSLog(@"Subscribing...");
__block void (^reportHandler)(NSArray * _Nullable value, NSError * _Nullable error);
[device subscribeWithQueue:queue
minInterval:2
maxInterval:60
params:nil
cacheContainer:attributeCacheContainer
attributeReportHandler:^(NSArray * value) {
NSLog(@"Received report: %@", value);
if (reportHandler) {
__auto_type handler = reportHandler;
reportHandler = nil;
handler(value, nil);
}
}
eventReportHandler:nil
errorHandler:^(NSError * error) {
NSLog(@"Received report error: %@", error);
if (reportHandler) {
__auto_type handler = reportHandler;
reportHandler = nil;
handler(nil, error);
}
}
subscriptionEstablished:^() {
[subscribeExpectation fulfill];
Expand Down
9 changes: 2 additions & 7 deletions src/darwin/Framework/CHIPTests/MTRTestKeys.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#import <Security/SecKey.h>

@interface MTRTestKeys ()
@property (readwrite, nonatomic, strong) SecKeyRef privateKey;
@property (readwrite, nonatomic, strong) SecKeyRef publicKey;
@property (readonly) SecKeyRef privateKey;
@property (readonly) SecKeyRef publicKey;
@end

@implementation MTRTestKeys
Expand Down Expand Up @@ -79,11 +79,6 @@ - (NSData *)signMessageECDSA_DER:(NSData *)message
return (__bridge_transfer NSData *) outData;
}

- (SecKeyRef)publicKey
{
return _publicKey;
}

- (void)dealloc
{
if (_publicKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (void)testThreadOperationalDataset
channel:25
panID:[NSData dataWithBytes:&panID length:sizeof(panID)]];
XCTAssertNotNil(dataset);
NSData * data = [dataset asData];
NSData * data = [dataset data];
XCTAssertNotNil(data);

MTRThreadOperationalDataset * reconstructed = [[MTRThreadOperationalDataset alloc] initWithData:data];
Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ - (void)test900_SubscribeAttributeCache
params:nil
cacheContainer:attributeCacheContainer
attributeReportHandler:^(NSArray * value) {
NSLog(@"Report for attribute cache: %@", error);
NSLog(@"Report for attribute cache: %@", value);
}
eventReportHandler:nil
errorHandler:^(NSError * error) {
Expand Down

0 comments on commit bf26067

Please sign in to comment.