From b28d813d453675e10908d6e37a4a4dacbbedce93 Mon Sep 17 00:00:00 2001 From: Jeff Tung <100387939+jtung-apple@users.noreply.github.com> Date: Tue, 26 Sep 2023 09:26:36 -0700 Subject: [PATCH 1/2] [Darwin] MTRDeviceTests test017 - fix resubscription expectation --- src/app/InteractionModelEngine.h | 2 +- .../Framework/CHIPTests/MTRDeviceTests.m | 19 +++++++++++-------- .../CHIPTests/TestHelpers/MTRTestKeys.m | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index e2e42cb0c19b66..9ef719f56c362b 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -679,7 +679,7 @@ CHIP_ERROR ReadSingleClusterData(const Access::SubjectDescriptor & aSubjectDescr /** * Check whether concrete attribute path is an "existent attribute path" in spec terms. * @param[in] aPath The concrete path of the data being read. - * @retval boolean + * @retval boolean true if the concrete attribute path indicates a single existing instance on the node */ bool ConcreteAttributePathExists(const ConcreteAttributePath & aPath); diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index 2fa2800e0dcf8c..3ae86c645e0758 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -75,6 +75,9 @@ static void WaitForCommissionee(XCTestExpectation * expectation) #ifdef DEBUG @interface MTRBaseDevice (Test) - (void)failSubscribers:(dispatch_queue_t)queue completion:(void (^)(void))completion; + +// Test function for whitebox testing ++ (id)CHIPEncodeAndDecodeNSObject:(id)object; @end #endif @@ -1558,9 +1561,14 @@ - (void)test017_TestMTRDeviceBasics delegate.onNotReachable = ^() { [subscriptionDroppedExpectation fulfill]; }; - XCTestExpectation * resubscriptionExpectation = [self expectationWithDescription:@"Resubscription has happened"]; + XCTestExpectation * resubscriptionReachableExpectation = + [self expectationWithDescription:@"Resubscription has become reachable"]; delegate.onReachable = ^() { - [resubscriptionExpectation fulfill]; + [resubscriptionReachableExpectation fulfill]; + }; + XCTestExpectation * resubscriptionGotReportsExpectation = [self expectationWithDescription:@"Resubscription got reports"]; + delegate.onReportEnd = ^() { + [resubscriptionGotReportsExpectation fulfill]; }; // reset the onAttributeDataReceived to validate the following resubscribe test @@ -1598,7 +1606,7 @@ - (void)test017_TestMTRDeviceBasics // Check that device resets start time on subscription drop XCTAssertNil(device.estimatedStartTime); - [self waitForExpectations:@[ resubscriptionExpectation ] timeout:60]; + [self waitForExpectations:@[ resubscriptionReachableExpectation, resubscriptionGotReportsExpectation ] timeout:60]; // Now make sure we ignore later tests. Ideally we would just unsubscribe // or remove the delegate, but there's no good way to do that. @@ -2585,11 +2593,6 @@ - (void)test999_TearDown @end -@interface MTRBaseDevice (Test) -// Test function for whitebox testing -+ (id)CHIPEncodeAndDecodeNSObject:(id)object; -@end - @interface MTRDeviceEncoderTests : XCTestCase @end diff --git a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m index 23b602e2e7208c..e6a74f25bdeccf 100644 --- a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m +++ b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m @@ -57,7 +57,7 @@ - (instancetype)init CFErrorRef error = NULL; const NSDictionary * keygenParams = @{ (__bridge NSString *) kSecAttrKeyClass : (__bridge NSString *) kSecAttrKeyClassPrivate, - (__bridge NSString *) kSecAttrKeyType : (__bridge NSNumber *) kSecAttrKeyTypeECSECPrimeRandom, + (__bridge NSString *) kSecAttrKeyType : (__bridge NSString *) kSecAttrKeyTypeECSECPrimeRandom, (__bridge NSString *) kSecAttrKeySizeInBits : @(keySizeInBits), (__bridge NSString *) kSecAttrIsPermanent : @(NO) }; From df26833f713238bf6ec951ef3f2629a744feb598 Mon Sep 17 00:00:00 2001 From: Jeff Tung <100387939+jtung-apple@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:12:36 -0700 Subject: [PATCH 2/2] Update src/app/InteractionModelEngine.h Co-authored-by: Boris Zbarsky --- src/app/InteractionModelEngine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index 9ef719f56c362b..0ecf3f6c6b1ec0 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -679,7 +679,7 @@ CHIP_ERROR ReadSingleClusterData(const Access::SubjectDescriptor & aSubjectDescr /** * Check whether concrete attribute path is an "existent attribute path" in spec terms. * @param[in] aPath The concrete path of the data being read. - * @retval boolean true if the concrete attribute path indicates a single existing instance on the node + * @retval boolean true if the concrete attribute path indicates an attribute that exists on the node. */ bool ConcreteAttributePathExists(const ConcreteAttributePath & aPath);