Skip to content

Commit

Permalink
[Darwin] MTRDeviceTests test017 - fix resubscription expectation (#29458
Browse files Browse the repository at this point in the history
)

* [Darwin] MTRDeviceTests test017 - fix resubscription expectation

* Update src/app/InteractionModelEngine.h

Co-authored-by: Boris Zbarsky <[email protected]>

---------

Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Oct 24, 2023
1 parent c80c3d1 commit 3350279
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 an attribute that exists on the node.
*/
bool ConcreteAttributePathExists(const ConcreteAttributePath & aPath);

Expand Down
19 changes: 11 additions & 8 deletions src/darwin/Framework/CHIPTests/MTRDeviceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down

0 comments on commit 3350279

Please sign in to comment.