From 1084436d7e4f99bcd53b36e368addc85a8b8abea Mon Sep 17 00:00:00 2001 From: ManjunathRA Date: Fri, 1 Apr 2022 04:38:42 +0530 Subject: [PATCH] Test added Mar 30 (#16825) * New tests added TC-DL-1.3 TC-PSCFG-1.1 * PSCFG-1.1 * Added auto generated files * Added LC-1.2 * Auto generated files after rebase Co-authored-by: manjunath-grl --- examples/chip-tool-darwin/templates/tests.js | 15 + examples/chip-tool/templates/tests/tests.js | 12 +- .../suites/certification/Test_TC_DL_1_3.yaml | 105 +++ .../suites/certification/Test_TC_LC_1_2.yaml | 39 + .../certification/Test_TC_PSCFG_1_1.yaml | 99 +-- .../Framework/CHIP/templates/tests/tests.js | 15 + .../Framework/CHIPTests/CHIPClustersTests.m | 330 +++++++ .../zap-generated/test/Commands.h | 546 ++++++++++++ .../chip-tool/zap-generated/test/Commands.h | 812 ++++++++++++++++-- 9 files changed, 1828 insertions(+), 145 deletions(-) create mode 100644 src/app/tests/suites/certification/Test_TC_DL_1_3.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_LC_1_2.yaml diff --git a/examples/chip-tool-darwin/templates/tests.js b/examples/chip-tool-darwin/templates/tests.js index cc6504c5d57934..be79558ba6020b 100644 --- a/examples/chip-tool-darwin/templates/tests.js +++ b/examples/chip-tool-darwin/templates/tests.js @@ -80,6 +80,10 @@ function getTests() 'Test_TC_DM_3_1', ]; + const DoorLock = [ + 'Test_TC_DL_1_3', + ]; + const ElectricalMeasurement = [ 'Test_TC_EMR_1_1', ]; @@ -194,6 +198,10 @@ function getTests() 'Test_TC_PCC_2_4', ]; + const PowerSourceConfiguration = [ + 'Test_TC_PSCFG_1_1', + ]; + const RelativeHumidityMeasurement = [ 'Test_TC_RH_1_1', 'Test_TC_RH_2_1', @@ -228,6 +236,10 @@ function getTests() 'Test_TC_DIAG_TH_NW_1_2', ]; + const UserLabel = [ + 'Test_TC_LC_1_2', + ]; + const WiFiNetworkDiagnostics = [ 'Test_TC_WIFIDIAG_1_1', 'Test_TC_WIFIDIAG_3_1', @@ -285,6 +297,7 @@ function getTests() ColorControl, // DeviceDiscovery, // DeviceManagement, // + DoorLock, // ElectricalMeasurement, // EthernetNetworkDiagnostics, // FlowMeasurement, // @@ -299,12 +312,14 @@ function getTests() PowerSource, // PressureMeasurement, // PumpConfigurationControl, // + PowerSourceConfiguration, // RelativeHumidityMeasurement, // Switch, // TemperatureMeasurement, // Thermostat, // ThermostatUserConfiguration, // ThreadNetworkDiagnostics, // + UserLabel, // WiFiNetworkDiagnostics, // WindowCovering, // Others, // diff --git a/examples/chip-tool/templates/tests/tests.js b/examples/chip-tool/templates/tests/tests.js index 53d546e21bbd8b..84e452267808b3 100644 --- a/examples/chip-tool/templates/tests/tests.js +++ b/examples/chip-tool/templates/tests/tests.js @@ -197,7 +197,6 @@ function getManualTests() ]; const PowerSourceConfiguration = [ - 'Test_TC_PSCFG_1_1', 'Test_TC_PSCFG_2_1', 'Test_TC_PSCFG_3_1', ]; @@ -380,6 +379,10 @@ function getTests() 'Test_TC_LVL_6_1', ]; + const UserLabel = [ + 'Test_TC_LC_1_2', + ]; + const MediaControl = [ 'Test_TC_MC_1_1', 'Test_TC_MC_1_2', @@ -452,6 +455,10 @@ function getTests() 'Test_TC_PCC_2_4', ]; + const PowerSourceConfiguration = [ + 'Test_TC_PSCFG_1_1', + ]; + const RelativeHumidityMeasurement = [ 'Test_TC_RH_1_1', 'Test_TC_RH_2_1', @@ -563,6 +570,7 @@ function getTests() 'DL_UsersAndCredentials', 'DL_LockUnlock', 'DL_Schedules', + 'Test_TC_DL_1_3', ]; const Groups = [ @@ -593,6 +601,7 @@ function getTests() PowerSource, // PressureMeasurement, // PumpConfigurationControl, // + PowerSourceConfiguration, // RelativeHumidityMeasurement, // SecureChannel, // Switch, // @@ -600,6 +609,7 @@ function getTests() Thermostat, // ThermostatUserConfiguration, // ThreadNetworkDiagnostics, // + UserLabel, // WiFiNetworkDiagnostics, // WindowCovering, // TV, // diff --git a/src/app/tests/suites/certification/Test_TC_DL_1_3.yaml b/src/app/tests/suites/certification/Test_TC_DL_1_3.yaml new file mode 100644 index 00000000000000..e4b4025ec42832 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_DL_1_3.yaml @@ -0,0 +1,105 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 106.3. [TC-DL-1.3] Verification for Unlock Door command [DUT-Server] + +config: + nodeId: 0x12344321 + cluster: "Door Lock" + endpoint: 1 + +tests: + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "Create new PIN credential and lock/unlock user" + command: "SetCredential" + timedInteractionTimeoutMs: 10000 + arguments: + values: + - name: "operationType" + value: 0 + - name: "credential" + value: { CredentialType: 1, CredentialIndex: 1 } + - name: "credentialData" + value: "123456" + - name: "userIndex" + value: null + - name: "userStatus" + value: null + - name: "userType" + value: null + response: + values: + - name: "status" + value: 0 + - name: "userIndex" + value: 1 + - name: "nextCredentialIndex" + value: 2 + + - label: "Precondition: Door is in locked state" + command: "LockDoor" + timedInteractionTimeoutMs: 10000 + arguments: + values: + - name: "PINCode" + value: "123456" + + - label: "TH writes AutoRelockTime attribute value as 10 seconds on the DUT" + command: "writeAttribute" + attribute: "AutoRelockTime" + arguments: + value: 10 + + - label: "TH sends the unlock Door command to the DUT with valid PINCode" + command: "UnlockDoor" + timedInteractionTimeoutMs: 10000 + arguments: + values: + - name: "PINCode" + value: "123456" + + - label: "TH reads AutoRelockTime attribute from DUT" + command: "readAttribute" + attribute: "AutoRelockTime" + response: + value: 10 + + - label: "Wait 10000ms" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 10000 + + - label: "TH reads LockState attriute" + command: "readAttribute" + attribute: "LockState" + response: + value: 1 + + - label: "Clean the created credential" + command: "ClearCredential" + timedInteractionTimeoutMs: 10000 + arguments: + values: + - name: "credential" + value: { CredentialType: 1, CredentialIndex: 1 } diff --git a/src/app/tests/suites/certification/Test_TC_LC_1_2.yaml b/src/app/tests/suites/certification/Test_TC_LC_1_2.yaml new file mode 100644 index 00000000000000..dbad91f9e932a8 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_LC_1_2.yaml @@ -0,0 +1,39 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: + 94.4. [TC-LC-1.4]User Label cluster constraint_error verification [DUT - + Commissionee] + +config: + nodeId: 0x12344321 + cluster: "User Label" + endpoint: 1 + +tests: + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "TH1 reads LabelList attribute from the DUT" + command: "readAttribute" + attribute: "label list" + response: + constraints: + - type: list + - minLength: 3 diff --git a/src/app/tests/suites/certification/Test_TC_PSCFG_1_1.yaml b/src/app/tests/suites/certification/Test_TC_PSCFG_1_1.yaml index 35223f9df417b0..d00cff3c02760d 100644 --- a/src/app/tests/suites/certification/Test_TC_PSCFG_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_PSCFG_1_1.yaml @@ -16,85 +16,50 @@ name: 63.1.1. [TC-PSCFG-1.1] Global attributes with server as DUT config: nodeId: 0x12344321 - cluster: "Basic" + cluster: "Power Source Configuration" endpoint: 0 tests: - label: "Commission DUT to TH" - verification: | - - disabled: true + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId - label: "TH reads the ClusterRevision attribute from the DUT" - verification: | - ./chip-tool powersourceconfiguration read cluster-revision 1234 0 - - - The response should look like this: - - [1641813555.191189][38097:38102] CHIP:DMG: ReportDataMessage = - [1641813555.191325][38097:38102] CHIP:DMG: { - [1641813555.191381][38097:38102] CHIP:DMG: AttributeReportIBs = - [1641813555.191456][38097:38102] CHIP:DMG: [ - [1641813555.191627][38097:38102] CHIP:DMG: AttributeReportIB = - [1641813555.191842][38097:38102] CHIP:DMG: { - [1641813555.191910][38097:38102] CHIP:DMG: AttributeDataIB = - [1641813555.191979][38097:38102] CHIP:DMG: { - [1641813555.192062][38097:38102] CHIP:DMG: DataVersion = 0x0, - [1641813555.192134][38097:38102] CHIP:DMG: AttributePathIB = - [1641813555.192212][38097:38102] CHIP:DMG: { - [1641813555.192302][38097:38102] CHIP:DMG: Endpoint = 0x0, - [1641813555.192386][38097:38102] CHIP:DMG: Cluster = 0x2e, - [1641813555.192471][38097:38102] CHIP:DMG: Attribute = 0x0000_FFFD, - [1641813555.192545][38097:38102] CHIP:DMG: } - [1641813555.192625][38097:38102] CHIP:DMG: - [1641813555.192697][38097:38102] CHIP:DMG: Data = 1, - [1641813555.192775][38097:38102] CHIP:DMG: }, - [1641813555.192849][38097:38102] CHIP:DMG: - [1641813555.192913][38097:38102] CHIP:DMG: }, - [1641813555.192984][38097:38102] CHIP:DMG: - [1641813555.193044][38097:38102] CHIP:DMG: ], - [1641813555.193115][38097:38102] CHIP:DMG: - [1641813555.193173][38097:38102] CHIP:DMG: SuppressResponse = true, - [1641813555.193227][38097:38102] CHIP:DMG: } - [1641813555.193482][38097:38102] CHIP:TOO: PowerSourceConfiguration.ClusterRevision response: 1 - disabled: true + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 1 - label: "TH reads the AttributeList attribute from the DUT" - verification: | - ./chip-tool powersourceconfiguration read attribute-list 1234 0 - - The response should look like this: - - [CHIP:DMG: SuppressResponse = true, - [CHIP:DMG: } - [CHIP:TOO: GeneralCommissioning.AttributeList response: 5 entries - [CHIP:TOO: [1]: 0 - [CHIP:TOO: [2]: 65529 - [CHIP:TOO: [3]: 65530 - [CHIP:TOO: [4]: 65531 - [CHIP:TOO: [5]: 65533 - disabled: true + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list - label: "TH reads the AcceptedCommandList attribute from the DUT" - verification: | - ./chip-tool powersourceconfiguration read client-generated-command-list 1234 0 - - [...] - [1646048092.858800][36301:36306] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_002E Attribute 0x0000_FFF9DataVersion: 502821112 - [1646048092.858890][36301:36306] CHIP:TOO: AcceptedCommandList: 0 entries - disabled: true + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list - label: "TH reads the GeneratedCommandList attribute from the DUT" - verification: | - ./chip-tool powersourceconfiguration read server-generated-command-list 1234 0 - - [...] - [1646048186.753316][36310:36315] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_002E Attribute 0x0000_FFF8DataVersion: 502821112 - [1646048186.753391][36310:36315] CHIP:TOO: GeneratedCommandList: 0 entries - disabled: true + command: "readAttribute" + attribute: "GeneratedCommandList" + response: + constraints: + type: list + #issue #11053 disabled steps below Global attributes missing from YAML framework - label: "TH reads the EventList attribute from the DUT" - verification: | - Not supported in SDK yet disabled: true + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list diff --git a/src/darwin/Framework/CHIP/templates/tests/tests.js b/src/darwin/Framework/CHIP/templates/tests/tests.js index 0047412c3c1c43..f5646108c6392f 100644 --- a/src/darwin/Framework/CHIP/templates/tests/tests.js +++ b/src/darwin/Framework/CHIP/templates/tests/tests.js @@ -80,6 +80,10 @@ function getTests() 'Test_TC_DM_3_1', ]; + const DoorLock = [ + 'Test_TC_DL_1_3', + ]; + const ElectricalMeasurement = [ 'Test_TC_EMR_1_1', ]; @@ -194,6 +198,10 @@ function getTests() 'Test_TC_PCC_2_4', ]; + const PowerSourceConfiguration = [ + 'Test_TC_PSCFG_1_1', + ]; + const RelativeHumidityMeasurement = [ 'Test_TC_RH_1_1', 'Test_TC_RH_2_1', @@ -228,6 +236,10 @@ function getTests() 'Test_TC_DIAG_TH_NW_1_2', ]; + const UserLabel = [ + 'Test_TC_LC_1_2', + ]; + const WiFiNetworkDiagnostics = [ 'Test_TC_WIFIDIAG_1_1', 'Test_TC_WIFIDIAG_3_1', @@ -287,6 +299,7 @@ function getTests() ColorControl, // DeviceDiscovery, // DeviceManagement, // + DoorLock, // ElectricalMeasurement, // EthernetNetworkDiagnostics, // FlowMeasurement, // @@ -301,12 +314,14 @@ function getTests() PowerSource, // PressureMeasurement, // PumpConfigurationControl, // + PowerSourceConfiguration, // RelativeHumidityMeasurement, // Switch, // TemperatureMeasurement, // Thermostat, // ThermostatUserConfiguration, // ThreadNetworkDiagnostics, // + UserLabel, // WiFiNetworkDiagnostics, // WindowCovering, // Others, // diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 5202eff3522ffe..6679d9f69106fa 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -12288,6 +12288,210 @@ - (void)testSendClusterTest_TC_DM_3_1_000002_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterTest_TC_DL_1_3_000000_WaitForCommissionee +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForCommissionee(expectation, queue, 305414945); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_DL_1_3_000001_SetCredential +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Create new PIN credential and lock/unlock user"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + __auto_type * params = [[CHIPDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:0]; + params.credential = [[CHIPDoorLockClusterDlCredential alloc] init]; + ((CHIPDoorLockClusterDlCredential *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1]; + ((CHIPDoorLockClusterDlCredential *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params + completionHandler:^(CHIPDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Create new PIN credential and lock/unlock user Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = values.status; + XCTAssertEqual([actualValue unsignedCharValue], 0); + } + { + id actualValue = values.userIndex; + XCTAssertFalse(actualValue == nil); + XCTAssertEqual([actualValue unsignedShortValue], 1U); + } + { + id actualValue = values.nextCredentialIndex; + XCTAssertFalse(actualValue == nil); + XCTAssertEqual([actualValue unsignedShortValue], 2U); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_DL_1_3_000002_LockDoor +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Precondition: Door is in locked state"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + __auto_type * params = [[CHIPDoorLockClusterLockDoorParams alloc] init]; + params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; + [cluster lockDoorWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"Precondition: Door is in locked state Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_DL_1_3_000003_WriteAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"TH writes AutoRelockTime attribute value as 10 seconds on the DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + id autoRelockTimeArgument; + autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH writes AutoRelockTime attribute value as 10 seconds on the DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_DL_1_3_000004_UnlockDoor +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"TH sends the unlock Door command to the DUT with valid PINCode"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + __auto_type * params = [[CHIPDoorLockClusterUnlockDoorParams alloc] init]; + params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; + [cluster unlockDoorWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH sends the unlock Door command to the DUT with valid PINCode Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_DL_1_3_000005_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"TH reads AutoRelockTime attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeAutoRelockTimeWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads AutoRelockTime attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertEqual([actualValue unsignedIntValue], 10UL); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_DL_1_3_000006_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Wait 10000ms"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 10000); + [self waitForExpectationsWithTimeout:(10000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_DL_1_3_000007_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"TH reads LockState attriute"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeLockStateWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads LockState attriute Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertFalse(actualValue == nil); + XCTAssertEqual([actualValue unsignedCharValue], 1); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_DL_1_3_000008_ClearCredential +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Clean the created credential"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + __auto_type * params = [[CHIPDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[CHIPDoorLockClusterDlCredential alloc] init]; + ((CHIPDoorLockClusterDlCredential *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1]; + ((CHIPDoorLockClusterDlCredential *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; + + [cluster clearCredentialWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"Clean the created credential Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterTest_TC_EMR_1_1_000000_WaitForCommissionee { XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; @@ -22290,6 +22494,104 @@ - (void)testSendClusterTest_TC_PCC_2_4_000011_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterTest_TC_PSCFG_1_1_000000_WaitForCommissionee +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Commission DUT to TH"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForCommissionee(expectation, queue, 305414945); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_PSCFG_1_1_000001_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"TH reads the ClusterRevision attribute from the DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestPowerSourceConfiguration * cluster = [[CHIPTestPowerSourceConfiguration alloc] initWithDevice:device + endpoint:0 + queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeClusterRevisionWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the ClusterRevision attribute from the DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertEqual([actualValue unsignedShortValue], 1U); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_PSCFG_1_1_000002_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"TH reads the AttributeList attribute from the DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestPowerSourceConfiguration * cluster = [[CHIPTestPowerSourceConfiguration alloc] initWithDevice:device + endpoint:0 + queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeAttributeListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the AttributeList attribute from the DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_PSCFG_1_1_000003_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"TH reads the AcceptedCommandList attribute from the DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestPowerSourceConfiguration * cluster = [[CHIPTestPowerSourceConfiguration alloc] initWithDevice:device + endpoint:0 + queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeAcceptedCommandListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the AcceptedCommandList attribute from the DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_PSCFG_1_1_000004_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"TH reads the GeneratedCommandList attribute from the DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestPowerSourceConfiguration * cluster = [[CHIPTestPowerSourceConfiguration alloc] initWithDevice:device + endpoint:0 + queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeGeneratedCommandListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the GeneratedCommandList attribute from the DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterTest_TC_RH_1_1_000000_WaitForCommissionee { XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; @@ -28521,6 +28823,34 @@ - (void)testSendClusterTest_TC_DIAG_TH_NW_1_2_000101_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterTest_TC_LC_1_2_000000_WaitForCommissionee +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForCommissionee(expectation, queue, 305414945); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_LC_1_2_000001_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"TH1 reads LabelList attribute from the DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestUserLabel * cluster = [[CHIPTestUserLabel alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeLabelListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH1 reads LabelList attribute from the DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterTest_TC_WIFIDIAG_1_1_000000_WaitForCommissionee { XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; diff --git a/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h b/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h index 94c043233b4353..7ba7618e92ca6d 100644 --- a/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h @@ -69,6 +69,7 @@ class TestList : public Command { printf("Test_TC_DD_1_9\n"); printf("Test_TC_DM_1_1\n"); printf("Test_TC_DM_3_1\n"); + printf("Test_TC_DL_1_3\n"); printf("Test_TC_EMR_1_1\n"); printf("Test_TC_ETHDIAG_1_1\n"); printf("Test_TC_ETHDIAG_2_1\n"); @@ -141,6 +142,7 @@ class TestList : public Command { printf("Test_TC_PCC_2_2\n"); printf("Test_TC_PCC_2_3\n"); printf("Test_TC_PCC_2_4\n"); + printf("Test_TC_PSCFG_1_1\n"); printf("Test_TC_RH_1_1\n"); printf("Test_TC_RH_2_1\n"); printf("Test_TC_RH_2_2\n"); @@ -157,6 +159,7 @@ class TestList : public Command { printf("Test_TC_TSUIC_2_2\n"); printf("Test_TC_DIAG_TH_NW_1_1\n"); printf("Test_TC_DIAG_TH_NW_1_2\n"); + printf("Test_TC_LC_1_2\n"); printf("Test_TC_WIFIDIAG_1_1\n"); printf("Test_TC_WIFIDIAG_3_1\n"); printf("Test_TC_WNCV_1_1\n"); @@ -15451,6 +15454,287 @@ class Test_TC_DM_3_1 : public TestCommandBridge { } }; +class Test_TC_DL_1_3 : public TestCommandBridge { +public: + Test_TC_DL_1_3() + : TestCommandBridge("Test_TC_DL_1_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + + ~Test_TC_DL_1_3() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DL_1_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DL_1_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Create new PIN credential and lock/unlock user\n"); + err = TestCreateNewPinCredentialAndLockUnlockUser_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Door is in locked state\n"); + err = TestPreconditionDoorIsInLockedState_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); + err = TestThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : TH sends the unlock Door command to the DUT with valid PINCode\n"); + err = TestThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : TH reads AutoRelockTime attribute from DUT\n"); + err = TestThReadsAutoRelockTimeAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10000ms\n"); + err = TestWait10000ms_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : TH reads LockState attriute\n"); + err = TestThReadsLockStateAttriute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Clean the created credential\n"); + err = TestCleanTheCreatedCredential_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinCredentialAndLockUnlockUser_1() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[CHIPDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:0]; + params.credential = [[CHIPDoorLockClusterDlCredential alloc] init]; + ((CHIPDoorLockClusterDlCredential *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1]; + ((CHIPDoorLockClusterDlCredential *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster + setCredentialWithParams:params + completionHandler:^(CHIPDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Create new PIN credential and lock/unlock user Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("status", actualValue, 0)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("userIndex", actualValue)); + VerifyOrReturn(CheckValue("userIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("nextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("nextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionDoorIsInLockedState_2() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[CHIPDoorLockClusterLockDoorParams alloc] init]; + params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; + [cluster lockDoorWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"Precondition: Door is in locked state Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_3() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id autoRelockTimeArgument; + autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH writes AutoRelockTime attribute value as 10 seconds on the DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_4() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[CHIPDoorLockClusterUnlockDoorParams alloc] init]; + params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; + [cluster unlockDoorWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH sends the unlock Door command to the DUT with valid PINCode Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThReadsAutoRelockTimeAttributeFromDut_5() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAutoRelockTimeWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads AutoRelockTime attribute from DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AutoRelockTime", actualValue, 10UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10000ms_6() + { + WaitForMs(10000); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThReadsLockStateAttriute_7() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLockStateWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads LockState attriute Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("LockState", actualValue)); + VerifyOrReturn(CheckValue("LockState", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCleanTheCreatedCredential_8() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestDoorLock * cluster = [[CHIPTestDoorLock alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[CHIPDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[CHIPDoorLockClusterDlCredential alloc] init]; + ((CHIPDoorLockClusterDlCredential *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1]; + ((CHIPDoorLockClusterDlCredential *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; + + [cluster clearCredentialWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"Clean the created credential Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + class Test_TC_EMR_1_1 : public TestCommandBridge { public: Test_TC_EMR_1_1() @@ -31000,6 +31284,175 @@ class Test_TC_PCC_2_4 : public TestCommandBridge { } }; +class Test_TC_PSCFG_1_1 : public TestCommandBridge { +public: + Test_TC_PSCFG_1_1() + : TestCommandBridge("Test_TC_PSCFG_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + + ~Test_TC_PSCFG_1_1() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PSCFG_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PSCFG_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH\n"); + err = TestCommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH reads the ClusterRevision attribute from the DUT\n"); + err = TestThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : TH reads the AttributeList attribute from the DUT\n"); + err = TestThReadsTheAttributeListAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestThReadsTheAcceptedCommandListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestThReadsTheGeneratedCommandListAttributeFromTheDut_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToTh_0() + { + WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThReadsTheClusterRevisionAttributeFromTheDut_1() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestPowerSourceConfiguration * cluster = [[CHIPTestPowerSourceConfiguration alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the ClusterRevision attribute from the DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThReadsTheAttributeListAttributeFromTheDut_2() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestPowerSourceConfiguration * cluster = [[CHIPTestPowerSourceConfiguration alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the AttributeList attribute from the DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThReadsTheAcceptedCommandListAttributeFromTheDut_3() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestPowerSourceConfiguration * cluster = [[CHIPTestPowerSourceConfiguration alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the AcceptedCommandList attribute from the DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThReadsTheGeneratedCommandListAttributeFromTheDut_4() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestPowerSourceConfiguration * cluster = [[CHIPTestPowerSourceConfiguration alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH reads the GeneratedCommandList attribute from the DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + class Test_TC_RH_1_1 : public TestCommandBridge { public: Test_TC_RH_1_1() @@ -38848,6 +39301,96 @@ class Test_TC_DIAG_TH_NW_1_2 : public TestCommandBridge { } }; +class Test_TC_LC_1_2 : public TestCommandBridge { +public: + Test_TC_LC_1_2() + : TestCommandBridge("Test_TC_LC_1_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + + ~Test_TC_LC_1_2() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LC_1_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LC_1_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads LabelList attribute from the DUT\n"); + err = TestTh1ReadsLabelListAttributeFromTheDut_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1ReadsLabelListAttributeFromTheDut_1() + { + CHIPDevice * device = GetConnectedDevice(); + CHIPTestUserLabel * cluster = [[CHIPTestUserLabel alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLabelListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH1 reads LabelList attribute from the DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + class Test_TC_WIFIDIAG_1_1 : public TestCommandBridge { public: Test_TC_WIFIDIAG_1_1() @@ -62476,6 +63019,7 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), @@ -62548,6 +63092,7 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), @@ -62564,6 +63109,7 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 44fac80f1ce2ed..604d4784494e8e 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -139,6 +139,7 @@ class TestList : public Command printf("Test_TC_PCC_2_2\n"); printf("Test_TC_PCC_2_3\n"); printf("Test_TC_PCC_2_4\n"); + printf("Test_TC_PSCFG_1_1\n"); printf("Test_TC_RH_1_1\n"); printf("Test_TC_RH_2_1\n"); printf("Test_TC_RH_2_2\n"); @@ -156,6 +157,7 @@ class TestList : public Command printf("Test_TC_TSUIC_2_2\n"); printf("Test_TC_DIAG_TH_NW_1_1\n"); printf("Test_TC_DIAG_TH_NW_1_2\n"); + printf("Test_TC_LC_1_2\n"); printf("Test_TC_WIFIDIAG_1_1\n"); printf("Test_TC_WIFIDIAG_3_1\n"); printf("Test_TC_WNCV_1_1\n"); @@ -207,6 +209,7 @@ class TestList : public Command printf("DL_UsersAndCredentials\n"); printf("DL_LockUnlock\n"); printf("DL_Schedules\n"); + printf("Test_TC_DL_1_3\n"); printf("TestGroupMessaging\n"); printf("TestGroupsCluster\n"); printf("TestGroupKeyManagementCluster\n"); @@ -346,7 +349,6 @@ class ManualTestList : public Command printf("Test_TC_SU_3_4\n"); printf("Test_TC_SU_4_1\n"); printf("Test_TC_SU_4_2\n"); - printf("Test_TC_PSCFG_1_1\n"); printf("Test_TC_PSCFG_2_1\n"); printf("Test_TC_PSCFG_3_1\n"); printf("Test_TC_SC_4_5\n"); @@ -42158,6 +42160,246 @@ class Test_TC_PCC_2_4Suite : public TestCommand } }; +class Test_TC_PSCFG_1_1Suite : public TestCommand +{ +public: + Test_TC_PSCFG_1_1Suite(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("Test_TC_PSCFG_1_1", credsIssuerConfig), mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + + ~Test_TC_PSCFG_1_1Suite() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PSCFG_1_1\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PSCFG_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH\n"); + err = TestCommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH reads the ClusterRevision attribute from the DUT\n"); + err = TestThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : TH reads the AttributeList attribute from the DUT\n"); + err = TestThReadsTheAttributeListAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestThReadsTheAcceptedCommandListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestThReadsTheGeneratedCommandListAttributeFromTheDut_4(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + void OnDiscoveryCommandsResults(const DiscoveryCommandResult & value) override + { + bool isExpectedDnssdResult = false; + + VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); + NextTest(); + } + + static void OnFailureCallback_1(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_1(error); + } + + static void OnSuccessCallback_1(void * context, uint16_t clusterRevision) + { + (static_cast(context))->OnSuccessResponse_1(clusterRevision); + } + + static void OnFailureCallback_2(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_2(error); + } + + static void OnSuccessCallback_2(void * context, const chip::app::DataModel::DecodableList & attributeList) + { + (static_cast(context))->OnSuccessResponse_2(attributeList); + } + + static void OnFailureCallback_3(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_3(error); + } + + static void OnSuccessCallback_3(void * context, + const chip::app::DataModel::DecodableList & acceptedCommandList) + { + (static_cast(context))->OnSuccessResponse_3(acceptedCommandList); + } + + static void OnFailureCallback_4(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_4(error); + } + + static void OnSuccessCallback_4(void * context, + const chip::app::DataModel::DecodableList & generatedCommandList) + { + (static_cast(context))->OnSuccessResponse_4(generatedCommandList); + } + + // + // Tests methods + // + + CHIP_ERROR TestCommissionDutToTh_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestThReadsTheClusterRevisionAttributeFromTheDut_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::PowerSourceConfigurationClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_1, OnFailureCallback_1, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_1(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_1(uint16_t clusterRevision) + { + VerifyOrReturn(CheckValue("clusterRevision", clusterRevision, 1U)); + + NextTest(); + } + + CHIP_ERROR TestThReadsTheAttributeListAttributeFromTheDut_2() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::PowerSourceConfigurationClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_2, OnFailureCallback_2, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_2(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_2(const chip::app::DataModel::DecodableList & attributeList) + { + VerifyOrReturn(CheckConstraintType("attributeList", "", "list")); + NextTest(); + } + + CHIP_ERROR TestThReadsTheAcceptedCommandListAttributeFromTheDut_3() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::PowerSourceConfigurationClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_3, OnFailureCallback_3, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_3(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_3(const chip::app::DataModel::DecodableList & acceptedCommandList) + { + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "", "list")); + NextTest(); + } + + CHIP_ERROR TestThReadsTheGeneratedCommandListAttributeFromTheDut_4() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::PowerSourceConfigurationClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_4, OnFailureCallback_4, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_4(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_4(const chip::app::DataModel::DecodableList & generatedCommandList) + { + VerifyOrReturn(CheckConstraintType("generatedCommandList", "", "list")); + NextTest(); + } +}; + class Test_TC_RH_1_1Suite : public TestCommand { public: @@ -53118,6 +53360,130 @@ class Test_TC_DIAG_TH_NW_1_2Suite : public TestCommand } }; +class Test_TC_LC_1_2Suite : public TestCommand +{ +public: + Test_TC_LC_1_2Suite(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("Test_TC_LC_1_2", credsIssuerConfig), mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + + ~Test_TC_LC_1_2Suite() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LC_1_2\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LC_1_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads LabelList attribute from the DUT\n"); + err = TestTh1ReadsLabelListAttributeFromTheDut_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + void OnDiscoveryCommandsResults(const DiscoveryCommandResult & value) override + { + bool isExpectedDnssdResult = false; + + VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); + NextTest(); + } + + static void OnFailureCallback_1(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_1(error); + } + + static void OnSuccessCallback_1( + void * context, + const chip::app::DataModel::DecodableList & labelList) + { + (static_cast(context))->OnSuccessResponse_1(labelList); + } + + // + // Tests methods + // + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestTh1ReadsLabelListAttributeFromTheDut_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::UserLabelClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_1, OnFailureCallback_1, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_1(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_1( + const chip::app::DataModel::DecodableList & labelList) + { + NextTest(); + } +}; + class Test_TC_WIFIDIAG_1_1Suite : public TestCommand { public: @@ -103817,6 +104183,371 @@ class DL_SchedulesSuite : public TestCommand } }; +class Test_TC_DL_1_3Suite : public TestCommand +{ +public: + Test_TC_DL_1_3Suite(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("Test_TC_DL_1_3", credsIssuerConfig), mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + + ~Test_TC_DL_1_3Suite() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DL_1_3\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DL_1_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Create new PIN credential and lock/unlock user\n"); + err = TestCreateNewPinCredentialAndLockUnlockUser_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Door is in locked state\n"); + err = TestPreconditionDoorIsInLockedState_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); + err = TestThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : TH sends the unlock Door command to the DUT with valid PINCode\n"); + err = TestThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : TH reads AutoRelockTime attribute from DUT\n"); + err = TestThReadsAutoRelockTimeAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10000ms\n"); + err = TestWait10000ms_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : TH reads LockState attriute\n"); + err = TestThReadsLockStateAttriute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Clean the created credential\n"); + err = TestCleanTheCreatedCredential_8(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + void OnDiscoveryCommandsResults(const DiscoveryCommandResult & value) override + { + bool isExpectedDnssdResult = false; + + VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); + NextTest(); + } + + static void OnFailureCallback_3(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_3(error); + } + + static void OnSuccessCallback_3(void * context) { (static_cast(context))->OnSuccessResponse_3(); } + + static void OnFailureCallback_5(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_5(error); + } + + static void OnSuccessCallback_5(void * context, uint32_t autoRelockTime) + { + (static_cast(context))->OnSuccessResponse_5(autoRelockTime); + } + + static void OnFailureCallback_7(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_7(error); + } + + static void OnSuccessCallback_7(void * context, + const chip::app::DataModel::Nullable & lockState) + { + (static_cast(context))->OnSuccessResponse_7(lockState); + } + + // + // Tests methods + // + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestCreateNewPinCredentialAndLockUnlockUser_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::DoorLock::Commands::SetCredential::Type; + + RequestType request; + request.operationType = static_cast(0); + + request.credential.credentialType = static_cast(1); + request.credential.credentialIndex = 1U; + + request.credentialData = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); + request.userIndex.SetNull(); + request.userStatus.SetNull(); + request.userType.SetNull(); + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context)) + ->OnSuccessResponse_1(data.status, data.userIndex, data.nextCredentialIndex); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_1(error); + }; + + ReturnErrorOnFailure( + chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request, 10000)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_1(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_1(chip::app::Clusters::DoorLock::DlStatus status, + const chip::app::DataModel::Nullable & userIndex, + const chip::app::DataModel::Nullable & nextCredentialIndex) + { + VerifyOrReturn(CheckValue("status", status, 0)); + + VerifyOrReturn(CheckValueNonNull("userIndex", userIndex)); + VerifyOrReturn(CheckValue("userIndex.Value()", userIndex.Value(), 1U)); + + VerifyOrReturn(CheckValueNonNull("nextCredentialIndex", nextCredentialIndex)); + VerifyOrReturn(CheckValue("nextCredentialIndex.Value()", nextCredentialIndex.Value(), 2U)); + + NextTest(); + } + + CHIP_ERROR TestPreconditionDoorIsInLockedState_2() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::DoorLock::Commands::LockDoor::Type; + + RequestType request; + request.pinCode.Emplace(); + request.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_2(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_2(error); + }; + + ReturnErrorOnFailure( + chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request, 10000)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_2(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_2() { NextTest(); } + + CHIP_ERROR TestThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_3() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::DoorLockClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + uint32_t autoRelockTimeArgument; + autoRelockTimeArgument = 10UL; + + ReturnErrorOnFailure(cluster.WriteAttribute( + autoRelockTimeArgument, this, OnSuccessCallback_3, OnFailureCallback_3)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_3(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_3() { NextTest(); } + + CHIP_ERROR TestThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_4() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type; + + RequestType request; + request.pinCode.Emplace(); + request.pinCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_4(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_4(error); + }; + + ReturnErrorOnFailure( + chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request, 10000)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_4(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_4() { NextTest(); } + + CHIP_ERROR TestThReadsAutoRelockTimeAttributeFromDut_5() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::DoorLockClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_5, OnFailureCallback_5, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_5(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_5(uint32_t autoRelockTime) + { + VerifyOrReturn(CheckValue("autoRelockTime", autoRelockTime, 10UL)); + + NextTest(); + } + + CHIP_ERROR TestWait10000ms_6() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(10000); + } + + CHIP_ERROR TestThReadsLockStateAttriute_7() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::DoorLockClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_7, OnFailureCallback_7, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_7(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_7(const chip::app::DataModel::Nullable & lockState) + { + VerifyOrReturn(CheckValueNonNull("lockState", lockState)); + VerifyOrReturn(CheckValue("lockState.Value()", lockState.Value(), 1)); + + NextTest(); + } + + CHIP_ERROR TestCleanTheCreatedCredential_8() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::DoorLock::Commands::ClearCredential::Type; + + RequestType request; + request.credential.SetNonNull(); + + request.credential.Value().credentialType = static_cast(1); + request.credential.Value().credentialIndex = 1U; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_8(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_8(error); + }; + + ReturnErrorOnFailure( + chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request, 10000)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_8(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_8() { NextTest(); } +}; + class TestGroupMessagingSuite : public TestCommand { public: @@ -116794,81 +117525,6 @@ class Test_TC_SU_4_2Suite : public TestCommand // }; -class Test_TC_PSCFG_1_1Suite : public TestCommand -{ -public: - Test_TC_PSCFG_1_1Suite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("Test_TC_PSCFG_1_1", credsIssuerConfig), mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_PSCFG_1_1Suite() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PSCFG_1_1\n"); - } - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PSCFG_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) - { - } - - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 0; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - void OnDiscoveryCommandsResults(const DiscoveryCommandResult & value) override - { - bool isExpectedDnssdResult = false; - - VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); - NextTest(); - } - - // - // Tests methods - // -}; - class Test_TC_PSCFG_2_1Suite : public TestCommand { public: @@ -118482,6 +119138,7 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), @@ -118499,6 +119156,7 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), @@ -118550,6 +119208,7 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), @@ -118678,7 +119337,6 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig),