Skip to content

Commit 217cd66

Browse files
committed
Fix the checkAttributeReportTriggersConfigurationChanged API and invert the expectation for device configuration changed when expectConfigurationChanged is set to NO
1 parent 214244a commit 217cd66

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/darwin/Framework/CHIPTests/MTRDeviceTests.m

+4-7
Original file line numberDiff line numberDiff line change
@@ -3082,6 +3082,7 @@ + (void)checkAttributeReportTriggersConfigurationChanged:(MTRAttributeIDType)att
30823082
XCTestExpectation * gotAttributeReportExpectation = [testcase expectationWithDescription:@"Attribute report has been received"];
30833083
XCTestExpectation * gotAttributeReportEndExpectation = [testcase expectationWithDescription:@"Attribute report has ended"];
30843084
XCTestExpectation * deviceConfigurationChangedExpectation = [testcase expectationWithDescription:@"Device configuration changed was receieved"];
3085+
deviceConfigurationChangedExpectation.inverted = !expectConfigurationChanged;
30853086

30863087
__block unsigned attributeReportsReceived = 0;
30873088
__block NSArray<NSDictionary<NSString *, id> *> * testDataValue = nil;
@@ -3125,19 +3126,15 @@ + (void)checkAttributeReportTriggersConfigurationChanged:(MTRAttributeIDType)att
31253126
__block BOOL wasOnDeviceConfigurationChangedCallbackCalled = NO;
31263127

31273128
delegate.onDeviceConfigurationChanged = ^() {
3128-
if (expectConfigurationChanged) {
31293129
[deviceConfigurationChangedExpectation fulfill];
3130-
}
31313130
wasOnDeviceConfigurationChangedCallbackCalled = YES;
31323131
};
31333132

31343133
[device unitTestInjectAttributeReport:attributeReport];
31353134

3136-
if (expectConfigurationChanged) {
3137-
[testcase waitForExpectations:@[ gotAttributeReportExpectation, gotAttributeReportEndExpectation, deviceConfigurationChangedExpectation ] timeout:kTimeoutInSeconds];
3138-
XCTAssertTrue(wasOnDeviceConfigurationChangedCallbackCalled);
3139-
} else {
3140-
[testcase waitForExpectations:@[ gotAttributeReportExpectation, gotAttributeReportEndExpectation ] timeout:kTimeoutInSeconds];
3135+
[testcase waitForExpectations:@[ gotAttributeReportExpectation, gotAttributeReportEndExpectation, deviceConfigurationChangedExpectation ] timeout:kTimeoutInSeconds];
3136+
if (!expectConfigurationChanged)
3137+
{
31413138
XCTAssertFalse(wasOnDeviceConfigurationChangedCallbackCalled);
31423139
}
31433140
}

0 commit comments

Comments
 (0)