Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable all the Darwin framework tests. #22781

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/darwin/Framework/CHIPTests/MTRDeviceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,58 @@ - (void)test900_SubscribeAllAttributes
#if !MANUAL_INDIVIDUAL_TEST
- (void)test999_TearDown
{
// Put the device back in the state we found it: open commissioning window, no fabrics commissioned.
MTRBaseDevice * device = GetConnectedDevice();
dispatch_queue_t queue = dispatch_get_main_queue();

// Get our current fabric index, for later deletion.
XCTestExpectation * readFabricIndexExpectation = [self expectationWithDescription:@"Fabric index read"];

__block NSNumber * fabricIndex;
__auto_type * opCredsCluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpoint:@(0) queue:queue];
[opCredsCluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable readError) {
XCTAssertNil(readError);
XCTAssertNotNil(value);
fabricIndex = value;
[readFabricIndexExpectation fulfill];
}];

[self waitForExpectations:@[ readFabricIndexExpectation ] timeout:kTimeoutInSeconds];

// Open a commissioning window.
XCTestExpectation * openCommissioningWindowExpectation = [self expectationWithDescription:@"Commissioning window opened"];

__auto_type * adminCommissioningCluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device
endpoint:@(0)
queue:queue];
__auto_type * openWindowParams = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init];
openWindowParams.commissioningTimeout = @(900);
openWindowParams.timedInvokeTimeoutMs = @(50000);
[adminCommissioningCluster openBasicCommissioningWindowWithParams:openWindowParams
completion:^(NSError * _Nullable error) {
XCTAssertNil(error);
[openCommissioningWindowExpectation fulfill];
}];

[self waitForExpectations:@[ openCommissioningWindowExpectation ] timeout:kTimeoutInSeconds];

// Remove our fabric from the device.
XCTestExpectation * removeFabricExpectation = [self expectationWithDescription:@"Fabric removed"];

__auto_type * removeParams = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init];
removeParams.fabricIndex = fabricIndex;

[opCredsCluster removeFabricWithParams:removeParams
completion:^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable removeError) {
XCTAssertNil(removeError);
XCTAssertNotNil(data);
XCTAssertEqualObjects(data.statusCode, @(0));
[removeFabricExpectation fulfill];
}];

[self waitForExpectations:@[ removeFabricExpectation ] timeout:kTimeoutInSeconds];

[self shutdownStack];
}
#endif
Expand Down
52 changes: 52 additions & 0 deletions src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,58 @@ - (void)test900_SubscribeClusterStateCache
#if !MANUAL_INDIVIDUAL_TEST
- (void)test999_TearDown
{
// Put the device back in the state we found it: open commissioning window, no fabrics commissioned.
MTRBaseDevice * device = [MTRBaseDevice deviceWithNodeID:@(kDeviceId) controller:sController];
dispatch_queue_t queue = dispatch_get_main_queue();

// Get our current fabric index, for later deletion.
XCTestExpectation * readFabricIndexExpectation = [self expectationWithDescription:@"Fabric index read"];

__block NSNumber * fabricIndex;
__auto_type * opCredsCluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpoint:@(0) queue:queue];
[opCredsCluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable readError) {
XCTAssertNil(readError);
XCTAssertNotNil(value);
fabricIndex = value;
[readFabricIndexExpectation fulfill];
}];

[self waitForExpectations:@[ readFabricIndexExpectation ] timeout:kTimeoutInSeconds];

// Open a commissioning window.
XCTestExpectation * openCommissioningWindowExpectation = [self expectationWithDescription:@"Commissioning window opened"];

__auto_type * adminCommissioningCluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device
endpoint:@(0)
queue:queue];
__auto_type * openWindowParams = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init];
openWindowParams.commissioningTimeout = @(900);
openWindowParams.timedInvokeTimeoutMs = @(50000);
[adminCommissioningCluster openBasicCommissioningWindowWithParams:openWindowParams
completion:^(NSError * _Nullable error) {
XCTAssertNil(error);
[openCommissioningWindowExpectation fulfill];
}];

[self waitForExpectations:@[ openCommissioningWindowExpectation ] timeout:kTimeoutInSeconds];

// Remove our fabric from the device.
XCTestExpectation * removeFabricExpectation = [self expectationWithDescription:@"Fabric removed"];

__auto_type * removeParams = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init];
removeParams.fabricIndex = fabricIndex;

[opCredsCluster removeFabricWithParams:removeParams
completion:^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data,
NSError * _Nullable removeError) {
XCTAssertNil(removeError);
XCTAssertNotNil(data);
XCTAssertEqualObjects(data.statusCode, @(0));
[removeFabricExpectation fulfill];
}];

[self waitForExpectations:@[ removeFabricExpectation ] timeout:kTimeoutInSeconds];

[self shutdownStack];
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
ReferencedContainer = "container:Matter.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "MTRXPCListenerSampleTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
Expand Down