From 1669200aed2664ad0896edbdcb7dd8b4ea0a8de8 Mon Sep 17 00:00:00 2001 From: Kiel Oleson Date: Fri, 17 May 2024 12:19:21 -0700 Subject: [PATCH] Darwin: remove `_handleAttributeReport` convenience method (#33489) * 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. --- src/darwin/Framework/CHIP/MTRDevice.mm | 11 +++-------- src/darwin/Framework/CHIPTests/MTRDeviceTests.m | 4 ++-- .../CHIPTests/TestHelpers/MTRTestDeclarations.h | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index ff2187c8e0fd61..61dbc643f5ccd1 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -1367,11 +1367,6 @@ - (void)_handleAttributeReport:(NSArray *> *)attrib [self _reportAttributes:[self _getAttributesToReportWithReportedValues:attributeReport fromSubscription:isFromSubscription]]; } -- (void)_handleAttributeReport:(NSArray *> *)attributeReport -{ - [self _handleAttributeReport:attributeReport fromSubscription:NO]; -} - #ifdef DEBUG - (void)unitTestInjectEventReport:(NSArray *> *)eventReport { @@ -1380,11 +1375,11 @@ - (void)unitTestInjectEventReport:(NSArray *> *)eve }); } -- (void)unitTestInjectAttributeReport:(NSArray *> *)attributeReport +- (void)unitTestInjectAttributeReport:(NSArray *> *)attributeReport fromSubscription:(BOOL)isFromSubscription { dispatch_async(self.queue, ^{ [self _handleReportBegin]; - [self _handleAttributeReport:attributeReport]; + [self _handleAttributeReport:attributeReport fromSubscription:isFromSubscription]; [self _handleReportEnd]; }); } @@ -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 diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index c05ee000b20e5f..1c2d5ddfe39a9a 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -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) { @@ -3530,7 +3530,7 @@ - (void)test033_TestMTRDeviceDeviceConfigurationChanged [deviceConfigurationChangedExpectationForAttributeReportWithMultipleAttributes fulfill]; }; - [device unitTestInjectAttributeReport:attributeReport]; + [device unitTestInjectAttributeReport:attributeReport fromSubscription:YES]; [self waitForExpectations:@[ gotAttributeReportWithMultipleAttributesExpectation, gotAttributeReportWithMultipleAttributesEndExpectation, deviceConfigurationChangedExpectationForAttributeReportWithMultipleAttributes ] timeout:kTimeoutInSeconds]; } diff --git a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestDeclarations.h b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestDeclarations.h index 119822099ce0a3..0cf5707c05c8b4 100644 --- a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestDeclarations.h +++ b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestDeclarations.h @@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN @interface MTRDevice (TestDebug) - (void)unitTestInjectEventReport:(NSArray *> *)eventReport; -- (void)unitTestInjectAttributeReport:(NSArray *> *)attributeReport; +- (void)unitTestInjectAttributeReport:(NSArray *> *)attributeReport fromSubscription:(BOOL)isFromSubscription; - (NSUInteger)unitTestAttributesReportedSinceLastCheck; - (void)unitTestClearClusterData; @end