Skip to content

Commit

Permalink
Address review comments and fix tests to work in the new setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Apr 16, 2024
1 parent 5ed6ad0 commit 5d7799e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,9 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath)

// Send read request to device if any of the following are true:
// 1. Subscription not in a state we can expect reports
// 2. The attribute has (or is assumed to have) the Changes Omitted quality, so we won't get reports for it.
// 2. The attribute has the Changes Omitted quality, so we won't get reports for it.
// 3. The attribute is not in the spec, and the read params asks to assume
// an unknown attribute has the Changes Omitted quality.
if (![self _subscriptionAbleToReport] || hasChangesOmittedQuality) {
// Read requests container will be a mutable array of items, each being an array containing:
// [attribute request path, params]
Expand Down
7 changes: 6 additions & 1 deletion src/darwin/Framework/CHIPTests/MTRDeviceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,10 @@ - (void)test017_TestMTRDeviceBasics
[self waitForExpectations:@[ onTimeWriteSuccess, onTimePreviousValue ] timeout:10];

// Test if errors are properly received
// TODO: We might stop reporting these altogether from MTRDevice, and then
// this test will need updating.
__auto_type * readThroughForUnknownAttributesParams = [[MTRReadParams alloc] init];
readThroughForUnknownAttributesParams.assumeUnknownAttributesReportable = NO;
XCTestExpectation * attributeReportErrorExpectation = [self expectationWithDescription:@"Attribute read error"];
delegate.onAttributeDataReceived = ^(NSArray<NSDictionary<NSString *, id> *> * data) {
for (NSDictionary<NSString *, id> * attributeReponseValue in data) {
Expand All @@ -1526,8 +1530,9 @@ - (void)test017_TestMTRDeviceBasics
}
}
};

// use the nonexistent attribute and expect read error
[device readAttributeWithEndpointID:testEndpointID clusterID:testClusterID attributeID:testAttributeID params:nil];
[device readAttributeWithEndpointID:testEndpointID clusterID:testClusterID attributeID:testAttributeID params:readThroughForUnknownAttributesParams];
[self waitForExpectations:@[ attributeReportErrorExpectation ] timeout:10];

// Resubscription test setup
Expand Down

0 comments on commit 5d7799e

Please sign in to comment.