Skip to content

Commit

Permalink
Fix subscription test
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Jul 2, 2022
1 parent 1519afc commit 280b113
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion 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 Expand Up @@ -774,7 +785,6 @@ - (void)test011_ReadCachedAttribute
[self waitForExpectations:[NSArray arrayWithObject:newSubscriptionEstablished] timeout:kTimeoutInSeconds];

__auto_type reportExpectation = [self expectationWithDescription:@"Report handler called"];
__block void (^reportHandler)(NSArray * _Nullable value, NSError * _Nullable error);
reportHandler = ^(NSArray * _Nullable value, NSError * _Nullable error) {
NSLog(@"Report received: %@, error: %@", value, error);
for (MTRAttributeReport * report in value) {
Expand Down

0 comments on commit 280b113

Please sign in to comment.