From d8e13586276f4a32b2cb7f58c408f88a0f9f8287 Mon Sep 17 00:00:00 2001 From: Jeff Tung <100387939+jtung-apple@users.noreply.github.com> Date: Sat, 7 Sep 2024 08:46:37 -0700 Subject: [PATCH] [Darwin] Fix MTRDevice getAllAttributesReport return value --- .../Framework/CHIP/MTRDevice_Concrete.mm | 8 +++++-- .../Framework/CHIPTests/MTRDeviceTests.m | 23 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm index 52acb7c0b4c09e..2a8ba3f189a285 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm +++ b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm @@ -3497,8 +3497,12 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray *newResponseValueDict in allAttributesReport) { + MTRAttributePath *newPath = newResponseValueDict[MTRAttributePathKey]; + NSDictionary *newDataValueDict = newResponseValueDict[MTRDataKey]; + NSNumber *newValue = newDataValueDict[MTRValueKey]; + XCTAssertNotNil(newValue); + + for (NSDictionary *originalResponseValueDict in attributeReport) { + MTRAttributePath *originalPath = originalResponseValueDict[MTRAttributePathKey]; + // Find same attribute path and compare value + if ([newPath isEqual:originalPath]) { + NSDictionary *originalDataValueDict = originalResponseValueDict[MTRDataKey]; + NSNumber *originalValue = originalDataValueDict[MTRValueKey]; + XCTAssertNotNil(originalValue); + XCTAssertEqualObjects(newValue, originalValue); + continue; + } + } + } } @end