Skip to content

Commit

Permalink
Darwin: remove _handleAttributeReport convenience method (#33489)
Browse files Browse the repository at this point in the history
* remove `_handleAttributeReport` convenience method; make `fromSubscription` explicit for remaining callsites

* correction to `unitTestInjectAttributeReport` - should have been `fromSubscription:YES`.  also allow configuration for all unit test attribute report injections.
  • Loading branch information
kiel-apple authored and pull[bot] committed Aug 27, 2024
1 parent 61d4ac8 commit 1669200
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
11 changes: 3 additions & 8 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1367,11 +1367,6 @@ - (void)_handleAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attrib
[self _reportAttributes:[self _getAttributesToReportWithReportedValues:attributeReport fromSubscription:isFromSubscription]];
}

- (void)_handleAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attributeReport
{
[self _handleAttributeReport:attributeReport fromSubscription:NO];
}

#ifdef DEBUG
- (void)unitTestInjectEventReport:(NSArray<NSDictionary<NSString *, id> *> *)eventReport
{
Expand All @@ -1380,11 +1375,11 @@ - (void)unitTestInjectEventReport:(NSArray<NSDictionary<NSString *, id> *> *)eve
});
}

- (void)unitTestInjectAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attributeReport
- (void)unitTestInjectAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attributeReport fromSubscription:(BOOL)isFromSubscription
{
dispatch_async(self.queue, ^{
[self _handleReportBegin];
[self _handleAttributeReport:attributeReport];
[self _handleAttributeReport:attributeReport fromSubscription:isFromSubscription];
[self _handleReportEnd];
});
}
Expand Down Expand Up @@ -2168,7 +2163,7 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath)
// Since the format is the same data-value dictionary, this looks like an
// attribute report
MTR_LOG_INFO("Read attribute work item [%llu] result: %@ [0x%016llX:%@:0x%llX:0x%llX]", workItemID, values, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
[self _handleAttributeReport:values];
[self _handleAttributeReport:values fromSubscription:NO];
}

// TODO: better retry logic
Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIPTests/MTRDeviceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -3202,7 +3202,7 @@ + (void)checkAttributeReportTriggersConfigurationChanged:(MTRAttributeIDType)att
wasOnDeviceConfigurationChangedCallbackCalled = YES;
};

[device unitTestInjectAttributeReport:attributeReport];
[device unitTestInjectAttributeReport:attributeReport fromSubscription:YES];

[testcase waitForExpectations:@[ gotAttributeReportExpectation, gotAttributeReportEndExpectation, deviceConfigurationChangedExpectation ] timeout:kTimeoutInSeconds];
if (!expectConfigurationChanged) {
Expand Down Expand Up @@ -3530,7 +3530,7 @@ - (void)test033_TestMTRDeviceDeviceConfigurationChanged
[deviceConfigurationChangedExpectationForAttributeReportWithMultipleAttributes fulfill];
};

[device unitTestInjectAttributeReport:attributeReport];
[device unitTestInjectAttributeReport:attributeReport fromSubscription:YES];
[self waitForExpectations:@[ gotAttributeReportWithMultipleAttributesExpectation, gotAttributeReportWithMultipleAttributesEndExpectation, deviceConfigurationChangedExpectationForAttributeReportWithMultipleAttributes ] timeout:kTimeoutInSeconds];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface MTRDevice (TestDebug)
- (void)unitTestInjectEventReport:(NSArray<NSDictionary<NSString *, id> *> *)eventReport;
- (void)unitTestInjectAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attributeReport;
- (void)unitTestInjectAttributeReport:(NSArray<NSDictionary<NSString *, id> *> *)attributeReport fromSubscription:(BOOL)isFromSubscription;
- (NSUInteger)unitTestAttributesReportedSinceLastCheck;
- (void)unitTestClearClusterData;
@end
Expand Down

0 comments on commit 1669200

Please sign in to comment.