Skip to content

Commit 07c89b2

Browse files
Address review comments and fix tests to work in the new setup.
1 parent 1c03091 commit 07c89b2

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+3-1
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,9 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath)
16271627

16281628
// Send read request to device if any of the following are true:
16291629
// 1. Subscription not in a state we can expect reports
1630-
// 2. The attribute has (or is assumed to have) the Changes Omitted quality, so we won't get reports for it.
1630+
// 2. The attribute has the Changes Omitted quality, so we won't get reports for it.
1631+
// 3. The attribute is not in the spec, and the read params asks to assume
1632+
// an unknown attribute has the Changes Omitted quality.
16311633
if (![self _subscriptionAbleToReport] || hasChangesOmittedQuality) {
16321634
// Read requests container will be a mutable array of items, each being an array containing:
16331635
// [attribute request path, params]

src/darwin/Framework/CHIPTests/MTRDeviceTests.m

+6-1
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,10 @@ - (void)test017_TestMTRDeviceBasics
15181518
[self waitForExpectations:@[ onTimeWriteSuccess, onTimePreviousValue ] timeout:10];
15191519

15201520
// Test if errors are properly received
1521+
// TODO: We might stop reporting these altogether from MTRDevice, and then
1522+
// this test will need updating.
1523+
__auto_type * readThroughForUnknownAttributesParams = [[MTRReadParams alloc] init];
1524+
readThroughForUnknownAttributesParams.assumeUnknownAttributesReportable = NO;
15211525
XCTestExpectation * attributeReportErrorExpectation = [self expectationWithDescription:@"Attribute read error"];
15221526
delegate.onAttributeDataReceived = ^(NSArray<NSDictionary<NSString *, id> *> * data) {
15231527
for (NSDictionary<NSString *, id> * attributeReponseValue in data) {
@@ -1526,8 +1530,9 @@ - (void)test017_TestMTRDeviceBasics
15261530
}
15271531
}
15281532
};
1533+
15291534
// use the nonexistent attribute and expect read error
1530-
[device readAttributeWithEndpointID:testEndpointID clusterID:testClusterID attributeID:testAttributeID params:nil];
1535+
[device readAttributeWithEndpointID:testEndpointID clusterID:testClusterID attributeID:testAttributeID params:readThroughForUnknownAttributesParams];
15311536
[self waitForExpectations:@[ attributeReportErrorExpectation ] timeout:10];
15321537

15331538
// Resubscription test setup

src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ class MTRSwiftDeviceTests : XCTestCase {
287287
wait(for: [ expectedValueReportedExpectation, expectedValueRemovedExpectation ], timeout: 5, enforceOrder: true)
288288

289289
// Test if errors are properly received
290+
// TODO: We might stop reporting these altogether from MTRDevice, and then
291+
// this test will need updating.
292+
let readThroughForUnknownAttributesParams = MTRReadParams()
293+
readThroughForUnknownAttributesParams.shouldAssumeUnknownAttributesReportable = false;
290294
let attributeReportErrorExpectation = expectation(description: "Attribute read error")
291295
delegate.onAttributeDataReceived = { (data: [[ String: Any ]]) -> Void in
292296
for attributeReponseValue in data {
@@ -296,7 +300,7 @@ class MTRSwiftDeviceTests : XCTestCase {
296300
}
297301
}
298302
// use the nonexistent attribute and expect read error
299-
device.readAttribute(withEndpointID: testEndpointID, clusterID: testClusterID, attributeID: testAttributeID, params: nil)
303+
device.readAttribute(withEndpointID: testEndpointID, clusterID: testClusterID, attributeID: testAttributeID, params: readThroughForUnknownAttributesParams)
300304
wait(for: [ attributeReportErrorExpectation ], timeout: 10)
301305

302306
// Resubscription test setup

0 commit comments

Comments
 (0)