Skip to content

Commit d873d21

Browse files
Apply suggestions from code review
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 928c255 commit d873d21

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

src/darwin/Framework/CHIP/MTRDevice.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ MTR_EXTERN NSString * const MTRDataVersionKey MTR_NEWLY_AVAILABLE;
426426
/**
427427
* This is called when the MTRDevice object detects a change in the device configuration.
428428
*
429-
* Device configuration is a set of functionality implemented by the device.
429+
* Device configuration is the set of functionality implemented by the device.
430430
*
431431
* The intention is that this is called whenever any of the things that usually don't change about a device might have changed.
432432
*/

src/darwin/Framework/CHIP/MTRDevice.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -2469,9 +2469,9 @@ - (void)_noteDataVersion:(NSNumber *)dataVersion forClusterPath:(MTRClusterPath
24692469
}
24702470
}
24712471

2472-
- (BOOL)_isAttributeAffectingDeviceConfigurationChanged:(MTRAttributePath *)attributePath
2472+
- (BOOL)_attributeAffectsDeviceConfiguration:(MTRAttributePath *)attributePath
24732473
{
2474-
// Check for attributes in the descriptor cluster that affect device configuration changed.
2474+
// Check for attributes in the descriptor cluster that affect device configuration.
24752475
if (attributePath.cluster.unsignedLongValue == MTRClusterIDTypeDescriptorID) {
24762476
switch (attributePath.attribute.unsignedLongValue) {
24772477
case MTRAttributeIDTypeClusterDescriptorAttributePartsListID:
@@ -2482,7 +2482,7 @@ - (BOOL)_isAttributeAffectingDeviceConfigurationChanged:(MTRAttributePath *)attr
24822482
}
24832483
}
24842484

2485-
// Check for global attributes that affect device configuration changed.
2485+
// Check for global attributes that affect device configuration.
24862486
switch (attributePath.attribute.unsignedLongValue) {
24872487
case MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID:
24882488
case MTRAttributeIDTypeGlobalAttributeAttributeListID:

src/darwin/Framework/CHIPTests/MTRDeviceTests.m

+10-12
Original file line numberDiff line numberDiff line change
@@ -1574,10 +1574,11 @@ - (void)test017_TestMTRDeviceBasics
15741574
[resubscriptionGotReportsExpectation fulfill];
15751575
};
15761576

1577-
// Set the onDeviceConfigurationChanged callback but do nothing. We shouldn't be called.
1578-
__block BOOL wasOnDeviceConfigurationChangedCallbackCalled = false;
1577+
// Make sure there are no device configuration changed notifications during this test.
1578+
// There is nothing changing about the server that would lead to those.
1579+
__block BOOL wasOnDeviceConfigurationChangedCallbackCalled = NO;
15791580
delegate.onDeviceConfigurationChanged = ^() {
1580-
wasOnDeviceConfigurationChangedCallbackCalled = true;
1581+
wasOnDeviceConfigurationChangedCallbackCalled = YES;
15811582
};
15821583

15831584
// reset the onAttributeDataReceived to validate the following resubscribe test
@@ -3052,8 +3053,8 @@ - (void)test032_MTRPathClassesEncoding
30523053
XCTAssertEqualObjects(originalCommandPath, decodedCommandPath);
30533054
}
30543055

3055-
// Helper API to test if changes in an attribute with a path specified by endpointId, clusterId and attributeId affect
3056-
// device configuration changed for a given MTRDevice. This API creates a fake attribute report for the given attribute path
3056+
// Helper API to test if changes in an attribute with a path specified by endpointId, clusterId and attributeId trigger
3057+
// device configuration changed callbacks for a given MTRDevice. This API creates a fake attribute report for the given attribute path
30573058
// and injects it into MTRDevice to exercise and test the delegate's device configuration changed callback.
30583059
+ (void)runTestDeviceConfigurationChangedForAttribute:(MTRAttributeIDType)attributeId
30593060
clusterId:(MTRClusterIDType)clusterId
@@ -3093,17 +3094,17 @@ + (void)runTestDeviceConfigurationChangedForAttribute:(MTRAttributeIDType)attrib
30933094
MTRAttributePath * attributePath = attributeDict[MTRAttributePathKey];
30943095
XCTAssertNotNil(attributePath);
30953096

3096-
XCTAssert(attributePath.cluster.unsignedLongValue == clusterId);
3097-
XCTAssert(attributePath.attribute.unsignedLongValue == attributeId);
3097+
XCTAssertEqualObjects(attributePath.cluster, @(clusterId));
3098+
XCTAssertEqualObjects(attributePath.attribute, @(attributeId));
30983099

30993100
NSDictionary * data = attributeDict[MTRDataKey];
31003101
XCTAssertNotNil(data);
3101-
XCTAssert([data[MTRDataVersionKey] isEqualToNumber:dataVersion]);
3102+
XCTAssertEqualObjects(data[MTRDataVersionKey], dataVersion);
31023103

31033104
NSArray<NSNumber *> * dataValue = data[MTRValueKey];
31043105
XCTAssertNotNil(dataValue);
31053106
XCTAssertNotNil(testDataValue);
3106-
XCTAssert([dataValue isEqual:testDataValue]);
3107+
XCTAssertEqualObjects(dataValue, testDataValue);
31073108
[gotAttributeReportExpectation fulfill];
31083109
}
31093110
};
@@ -3187,13 +3188,11 @@ - (void)test033_TestMTRDeviceDeviceConfigurationChanged
31873188
switch (attributePath.attribute.unsignedLongValue) {
31883189
case MTRAttributeIDTypeGlobalAttributeAttributeListID: {
31893190
dataVersionForAttributeList = data[MTRDataVersionKey];
3190-
;
31913191
XCTAssertNotNil(dataVersionForAttributeList);
31923192
break;
31933193
}
31943194
case MTRAttributeIDTypeGlobalAttributeClusterRevisionID: {
31953195
dataVersionForClusterRevision = data[MTRDataVersionKey];
3196-
;
31973196
XCTAssertNotNil(dataVersionForClusterRevision);
31983197
break;
31993198
}
@@ -3202,7 +3201,6 @@ - (void)test033_TestMTRDeviceDeviceConfigurationChanged
32023201
NSDictionary * data = attributeDict[MTRDataKey];
32033202
XCTAssertNotNil(data);
32043203
dataVersionForAcceptedCommandList = data[MTRDataVersionKey];
3205-
;
32063204
XCTAssertNotNil(dataVersionForAcceptedCommandList);
32073205
} else if (attributePath.cluster.unsignedLongValue == MTRClusterIDTypeGroupsID && attributePath.attribute.unsignedLongValue == MTRAttributeIDTypeGlobalAttributeFeatureMapID) {
32083206
NSDictionary * data = attributeDict[MTRDataKey];

0 commit comments

Comments
 (0)