From 2493648769384b16188ad1af487fd5c828c67410 Mon Sep 17 00:00:00 2001 From: Vikram Bhat Date: Wed, 27 Oct 2021 18:51:06 +0530 Subject: [PATCH] Test Scripts Added Test_TC_OCC_2_1, Test_TC_PCC_2_2, Test_TC_PCC_2_3, Test_TC_RH_2_1 (#10955) * Adding YAML Test Scripts 1.Test_TC_OCC_2_1 2.Test_TC_PCC_2_2 3.Test_TC_PCC_2_3 4.Test_TC_RH_2_1 * Updating generated test script artifacts * Update PCC attributes names since 10962 has landed Co-authored-by: Vivien Nicolas --- examples/chip-tool/templates/tests.js | 4 + .../suites/certification/Test_TC_OCC_2_1.yaml | 115 +++ .../suites/certification/Test_TC_PCC_2_2.yaml | 59 ++ .../suites/certification/Test_TC_PCC_2_3.yaml | 116 +++ .../suites/certification/Test_TC_RH_2_1.yaml | 84 ++ src/darwin/Framework/CHIP/templates/tests.js | 4 + .../Framework/CHIPTests/CHIPClustersTests.m | 363 +++++++++ .../chip-tool/zap-generated/test/Commands.h | 736 +++++++++++++++++- 8 files changed, 1473 insertions(+), 8 deletions(-) create mode 100644 src/app/tests/suites/certification/Test_TC_OCC_2_1.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_PCC_2_2.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_PCC_2_3.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_RH_2_1.yaml diff --git a/examples/chip-tool/templates/tests.js b/examples/chip-tool/templates/tests.js index 960acac831ccae..12fe1d08ffa5ef 100644 --- a/examples/chip-tool/templates/tests.js +++ b/examples/chip-tool/templates/tests.js @@ -57,6 +57,7 @@ function getTests() const OccupancySensing = [ 'Test_TC_OCC_1_1', + 'Test_TC_OCC_2_1', ]; const LevelControl = [ @@ -84,10 +85,13 @@ function getTests() const PumpConfigurationControl = [ 'Test_TC_PCC_1_1', 'Test_TC_PCC_2_1', + 'Test_TC_PCC_2_2', + 'Test_TC_PCC_2_3', ]; const RelativeHumidityMeasurement = [ 'Test_TC_RH_1_1', + 'Test_TC_RH_2_1', ]; const TemperatureMeasurement = [ diff --git a/src/app/tests/suites/certification/Test_TC_OCC_2_1.yaml b/src/app/tests/suites/certification/Test_TC_OCC_2_1.yaml new file mode 100644 index 00000000000000..8bf1a7583ac679 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_OCC_2_1.yaml @@ -0,0 +1,115 @@ +# 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: 30.2.1. [TC-OCC-2.1] Attributes with server as DUT + +config: + cluster: "Occupancy Sensing" + endpoint: 1 + +tests: + - label: "Reads mandatory attribute: Occupancy" + disabled: true + command: "readAttribute" + attribute: "occupancy" + response: + value: 0 + + - label: "Reads mandatory attribute constrains: Occupancy" + command: "readAttribute" + attribute: "occupancy" + response: + constraints: + type: map8 + minValue: 0 + maxValue: 1 + + - label: + "Writes the respective default value to mandatory attribute: Occupancy" + command: "writeAttribute" + attribute: "occupancy" + arguments: + value: 0 + response: + error: 1 + + - label: "Reads back mandatory attribute: Occupancy" + command: "readAttribute" + attribute: "occupancy" + response: + value: 0 + + - label: "Reads mandatory attribute: OccupancySensorType" + disabled: true + command: "readAttribute" + attribute: "occupancy sensor type" + response: + value: 0 + + - label: "Reads mandatory attribute constrains: OccupancySensorType" + command: "readAttribute" + attribute: "occupancy sensor type" + response: + constraints: + type: enum8 + minValue: 0 + maxValue: 3 + + - label: + "Writes the respective default value to mandatory attribute: + OccupancySensorType" + command: "writeAttribute" + attribute: "occupancy sensor type" + arguments: + value: 0 + response: + error: 1 + + - label: "Reads back mandatory attribute: OccupancySensorType" + command: "readAttribute" + attribute: "occupancy sensor type" + response: + value: 0 + + - label: "Reads mandatory attribute: OccupancySensorTypeBitmap" + disabled: true + command: "readAttribute" + attribute: "occupancy sensor type bitmap" + response: + value: 0 + + - label: "Reads mandatory attribute constrains: OccupancySensorTypeBitmap" + command: "readAttribute" + attribute: "occupancy sensor type bitmap" + response: + constraints: + type: map8 + minValue: 1 + maxValue: 7 + + - label: + "Writes the respective default value to mandatory attribute: + OccupancySensorTypeBitmap" + command: "writeAttribute" + attribute: "occupancy sensor type bitmap" + arguments: + value: 1 + response: + error: 1 + + - label: "Reads back mandatory attribute: OccupancySensorTypeBitmap" + command: "readAttribute" + attribute: "occupancy sensor type bitmap" + response: + value: 1 diff --git a/src/app/tests/suites/certification/Test_TC_PCC_2_2.yaml b/src/app/tests/suites/certification/Test_TC_PCC_2_2.yaml new file mode 100644 index 00000000000000..a36a2319fb884b --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_PCC_2_2.yaml @@ -0,0 +1,59 @@ +# 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: 15.2.2. [TC-PCC-2.2] Primary functionality with server as DUT + +config: + cluster: "Pump Configuration and Control" + endpoint: 1 + +tests: + - label: "Write 1 to the OperationMode attribute to DUT: OperationMode" + command: "writeAttribute" + attribute: "OperationMode" + arguments: + value: 1 + + - label: "Reads the attribute: EffectiveOperationMode" + disabled: true + command: "readAttribute" + attribute: "EffectiveOperationMode" + response: + value: 1 + + - label: "Write 2 to the OperationMode attribute to DUT: OperationMode" + command: "writeAttribute" + attribute: "OperationMode" + arguments: + value: 2 + + - label: "Reads the attribute: EffectiveOperationMode" + disabled: true + command: "readAttribute" + attribute: "EffectiveOperationMode" + response: + value: 2 + + - label: "Write 3 to the OperationMode attribute to DUT: OperationMode" + command: "writeAttribute" + attribute: "OperationMode" + arguments: + value: 3 + + - label: "Reads the attribute: EffectiveOperationMode" + disabled: true + command: "readAttribute" + attribute: "EffectiveOperationMode" + response: + value: 3 diff --git a/src/app/tests/suites/certification/Test_TC_PCC_2_3.yaml b/src/app/tests/suites/certification/Test_TC_PCC_2_3.yaml new file mode 100644 index 00000000000000..7d1da7c169ebab --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_PCC_2_3.yaml @@ -0,0 +1,116 @@ +# 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: 15.2.3. [TC-PCC-2.3] Primary functionality with server as DUT + +config: + cluster: "Pump Configuration and Control" + endpoint: 1 + +tests: + - label: "Write 0 to the OperationMode attribute to DUT" + command: "writeAttribute" + attribute: "OperationMode" + arguments: + value: 0 + + - label: "Reads the attribute: EffectiveOperationMode" + command: "readAttribute" + attribute: "EffectiveOperationMode" + response: + value: 0 + + - label: "Write 0 to the ControlMode attribute to DUT" + disabled: true + command: "writeAttribute" + attribute: "ControlMode" + arguments: + value: 0 + + - label: "Reads the attribute: EffectiveControlMode" + disabled: true + command: "readAttribute" + attribute: "EffectiveControlMode" + response: + value: 0 + + - label: "Write 1 to the ControlMode attribute to DUT" + disabled: true + command: "writeAttribute" + attribute: "ControlMode" + arguments: + value: 1 + + - label: "Reads the attribute: EffectiveControlMode" + disabled: true + command: "readAttribute" + attribute: "EffectiveControlMode" + response: + value: 1 + + - label: "Write 2 to the ControlMode attribute to DUT" + disabled: true + command: "writeAttribute" + attribute: "ControlMode" + arguments: + value: 2 + + - label: "Reads the attribute: EffectiveControlMode" + disabled: true + command: "readAttribute" + attribute: "EffectiveControlMode" + response: + value: 2 + + - label: "Write 3 to the ControlMode attribute to DUT" + disabled: true + command: "writeAttribute" + attribute: "ControlMode" + arguments: + value: 3 + + - label: "Reads the attribute: EffectiveControlMode" + disabled: true + command: "readAttribute" + attribute: "EffectiveControlMode" + response: + value: 3 + + - label: "Write 5 to the ControlMode attribute to DUT" + disabled: true + command: "writeAttribute" + attribute: "ControlMode" + arguments: + value: 5 + + - label: "Reads the attribute: EffectiveControlMode" + disabled: true + command: "readAttribute" + attribute: "EffectiveControlMode" + response: + value: 5 + + - label: "Write 7 to the ControlMode attribute to DUT" + disabled: true + command: "writeAttribute" + attribute: "ControlMode" + arguments: + value: 7 + + - label: "Reads the attribute: EffectiveControlMode" + disabled: true + command: "readAttribute" + attribute: "EffectiveControlMode" + response: + value: 7 diff --git a/src/app/tests/suites/certification/Test_TC_RH_2_1.yaml b/src/app/tests/suites/certification/Test_TC_RH_2_1.yaml new file mode 100644 index 00000000000000..1ccf2d58cba84a --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_RH_2_1.yaml @@ -0,0 +1,84 @@ +# 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: 9.2.1. [TC-RH-2.1] Attributes with server as DUT + +config: + cluster: "Relative Humidity Measurement" + endpoint: 1 + +tests: + - label: "Reads the mandatory attribute: MeasuredValue" + disabled: true + command: "readAttribute" + attribute: "measured value" + response: + value: 65535 + + - label: "Reads constraints of attribute: MeasuredValue" + command: "readAttribute" + attribute: "measured value" + response: + constraints: + type: uint16 + + - label: "Reads the mandatory attribute: MinMeasuredValue" + disabled: true + command: "readAttribute" + attribute: "min measured value" + response: + value: 65535 + + - label: "Reads constraints of attribute: MinMeasuredValue" + command: "readAttribute" + attribute: "min measured value" + response: + constraints: + type: uint16 + minValue: 0 + maxValue: 9999 + + - label: "Reads the mandatory attribute: MaxMeasuredValue" + disabled: true + command: "readAttribute" + attribute: "max measured value" + response: + value: 65535 + + - label: "Reads constraints of attribute: MaxMeasuredValue" + disabled: true + command: "readAttribute" + attribute: "max measured value" + response: + constraints: + type: uint16 + minValue: 1 + maxValue: 10000 + + - label: "Reads the optional attribute: Tolerance" + disabled: true + command: "readAttribute" + attribute: "tolerance" + response: + value: 0 + + - label: "Reads constraints of attribute: Tolerance" + disabled: true + command: "readAttribute" + attribute: "tolerance" + response: + constraints: + type: uint16 + minValue: 0 + maxValue: 2048 diff --git a/src/darwin/Framework/CHIP/templates/tests.js b/src/darwin/Framework/CHIP/templates/tests.js index f6031dbe25997d..410c32582fedb6 100644 --- a/src/darwin/Framework/CHIP/templates/tests.js +++ b/src/darwin/Framework/CHIP/templates/tests.js @@ -57,6 +57,7 @@ function getTests() const OccupancySensing = [ 'Test_TC_OCC_1_1', + 'Test_TC_OCC_2_1', ]; const LevelControl = [ @@ -84,10 +85,13 @@ function getTests() const PumpConfigurationControl = [ 'Test_TC_PCC_1_1', 'Test_TC_PCC_2_1', + 'Test_TC_PCC_2_2', + 'Test_TC_PCC_2_3', ]; const RelativeHumidityMeasurement = [ 'Test_TC_RH_1_1', + 'Test_TC_RH_2_1', ]; const TemperatureMeasurement = [ diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 6b8b5638b46b59..a301259bf075ad 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -7282,6 +7282,204 @@ - (void)testSendClusterTest_TC_OCC_1_1_000001_WriteAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterTest_TC_OCC_2_1_000000_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Reads mandatory attribute constrains: Occupancy"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestOccupancySensing * cluster = [[CHIPTestOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeOccupancyWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Reads mandatory attribute constrains: Occupancy Error: %@", err); + + XCTAssertEqual(err.code, 0); + + XCTAssertLessThanOrEqual([values[@"value"] unsignedCharValue], 1); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_OCC_2_1_000001_WriteAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Writes the respective default value to mandatory attribute: Occupancy"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestOccupancySensing * cluster = [[CHIPTestOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + uint8_t occupancyArgument = 0; + [cluster writeAttributeOccupancyWithValue:occupancyArgument + responseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Writes the respective default value to mandatory attribute: Occupancy Error: %@", err); + + XCTAssertEqual(err.code, 1); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_OCC_2_1_000002_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Reads back mandatory attribute: Occupancy"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestOccupancySensing * cluster = [[CHIPTestOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeOccupancyWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Reads back mandatory attribute: Occupancy Error: %@", err); + + XCTAssertEqual(err.code, 0); + + XCTAssertEqual([values[@"value"] unsignedCharValue], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_OCC_2_1_000003_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Reads mandatory attribute constrains: OccupancySensorType"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestOccupancySensing * cluster = [[CHIPTestOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeOccupancySensorTypeWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Reads mandatory attribute constrains: OccupancySensorType Error: %@", err); + + XCTAssertEqual(err.code, 0); + + XCTAssertLessThanOrEqual([values[@"value"] unsignedCharValue], 3); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_OCC_2_1_000004_WriteAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Writes the respective default value to mandatory attribute: OccupancySensorType"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestOccupancySensing * cluster = [[CHIPTestOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + uint8_t occupancySensorTypeArgument = 0; + [cluster writeAttributeOccupancySensorTypeWithValue:occupancySensorTypeArgument + responseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Writes the respective default value to mandatory attribute: " + @"OccupancySensorType Error: %@", + err); + + XCTAssertEqual(err.code, 1); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_OCC_2_1_000005_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Reads back mandatory attribute: OccupancySensorType"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestOccupancySensing * cluster = [[CHIPTestOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeOccupancySensorTypeWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Reads back mandatory attribute: OccupancySensorType Error: %@", err); + + XCTAssertEqual(err.code, 0); + + XCTAssertEqual([values[@"value"] unsignedCharValue], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_OCC_2_1_000006_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Reads mandatory attribute constrains: OccupancySensorTypeBitmap"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestOccupancySensing * cluster = [[CHIPTestOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeOccupancySensorTypeBitmapWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Reads mandatory attribute constrains: OccupancySensorTypeBitmap Error: %@", err); + + XCTAssertEqual(err.code, 0); + + XCTAssertGreaterThanOrEqual([values[@"value"] unsignedCharValue], 1); + XCTAssertLessThanOrEqual([values[@"value"] unsignedCharValue], 7); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_OCC_2_1_000007_WriteAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Writes the respective default value to mandatory attribute: OccupancySensorTypeBitmap"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestOccupancySensing * cluster = [[CHIPTestOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + uint8_t occupancySensorTypeBitmapArgument = 1; + [cluster writeAttributeOccupancySensorTypeBitmapWithValue:occupancySensorTypeBitmapArgument + responseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Writes the respective default value to mandatory attribute: " + @"OccupancySensorTypeBitmap Error: %@", + err); + + XCTAssertEqual(err.code, 1); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_OCC_2_1_000008_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Reads back mandatory attribute: OccupancySensorTypeBitmap"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestOccupancySensing * cluster = [[CHIPTestOccupancySensing alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeOccupancySensorTypeBitmapWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Reads back mandatory attribute: OccupancySensorTypeBitmap Error: %@", err); + + XCTAssertEqual(err.code, 0); + + XCTAssertEqual([values[@"value"] unsignedCharValue], 1); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterTest_TC_OO_1_1_000000_ReadAttribute { XCTestExpectation * expectation = [self expectationWithDescription:@"read the global attribute: ClusterRevision"]; @@ -8140,6 +8338,126 @@ - (void)testSendClusterTest_TC_PCC_2_1_000007_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterTest_TC_PCC_2_2_000000_WriteAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Write 1 to the OperationMode attribute to DUT: OperationMode"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestPumpConfigurationAndControl * cluster = [[CHIPTestPumpConfigurationAndControl alloc] initWithDevice:device + endpoint:1 + queue:queue]; + XCTAssertNotNil(cluster); + + uint8_t operationModeArgument = 1; + [cluster writeAttributeOperationModeWithValue:operationModeArgument + responseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Write 1 to the OperationMode attribute to DUT: OperationMode Error: %@", err); + + XCTAssertEqual(err.code, 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_PCC_2_2_000001_WriteAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Write 2 to the OperationMode attribute to DUT: OperationMode"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestPumpConfigurationAndControl * cluster = [[CHIPTestPumpConfigurationAndControl alloc] initWithDevice:device + endpoint:1 + queue:queue]; + XCTAssertNotNil(cluster); + + uint8_t operationModeArgument = 2; + [cluster writeAttributeOperationModeWithValue:operationModeArgument + responseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Write 2 to the OperationMode attribute to DUT: OperationMode Error: %@", err); + + XCTAssertEqual(err.code, 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_PCC_2_2_000002_WriteAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Write 3 to the OperationMode attribute to DUT: OperationMode"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestPumpConfigurationAndControl * cluster = [[CHIPTestPumpConfigurationAndControl alloc] initWithDevice:device + endpoint:1 + queue:queue]; + XCTAssertNotNil(cluster); + + uint8_t operationModeArgument = 3; + [cluster writeAttributeOperationModeWithValue:operationModeArgument + responseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Write 3 to the OperationMode attribute to DUT: OperationMode Error: %@", err); + + XCTAssertEqual(err.code, 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterTest_TC_PCC_2_3_000000_WriteAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Write 0 to the OperationMode attribute to DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestPumpConfigurationAndControl * cluster = [[CHIPTestPumpConfigurationAndControl alloc] initWithDevice:device + endpoint:1 + queue:queue]; + XCTAssertNotNil(cluster); + + uint8_t operationModeArgument = 0; + [cluster writeAttributeOperationModeWithValue:operationModeArgument + responseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Write 0 to the OperationMode attribute to DUT Error: %@", err); + + XCTAssertEqual(err.code, 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_PCC_2_3_000001_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Reads the attribute: EffectiveOperationMode"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestPumpConfigurationAndControl * cluster = [[CHIPTestPumpConfigurationAndControl alloc] initWithDevice:device + endpoint:1 + queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeEffectiveOperationModeWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Reads the attribute: EffectiveOperationMode Error: %@", err); + + XCTAssertEqual(err.code, 0); + + XCTAssertEqual([values[@"value"] unsignedCharValue], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterTest_TC_RH_1_1_000000_WriteAttribute { XCTestExpectation * expectation = @@ -8165,6 +8483,51 @@ - (void)testSendClusterTest_TC_RH_1_1_000000_WriteAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterTest_TC_RH_2_1_000000_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Reads constraints of attribute: MeasuredValue"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestRelativeHumidityMeasurement * cluster = [[CHIPTestRelativeHumidityMeasurement alloc] initWithDevice:device + endpoint:1 + queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeMeasuredValueWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Reads constraints of attribute: MeasuredValue Error: %@", err); + + XCTAssertEqual(err.code, 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_RH_2_1_000001_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Reads constraints of attribute: MinMeasuredValue"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestRelativeHumidityMeasurement * cluster = [[CHIPTestRelativeHumidityMeasurement alloc] initWithDevice:device + endpoint:1 + queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeMinMeasuredValueWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"Reads constraints of attribute: MinMeasuredValue Error: %@", err); + + XCTAssertEqual(err.code, 0); + + XCTAssertLessThanOrEqual([values[@"value"] unsignedShortValue], 9999); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterTest_TC_TM_1_1_000000_ReadAttribute { XCTestExpectation * expectation = [self expectationWithDescription:@"read the global attribute: ClusterRevision"]; diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index af2d055a782850..13f26b14274534 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -12149,6 +12149,353 @@ class Test_TC_OCC_1_1 : public TestCommand void OnSuccessResponse_1(uint16_t clusterRevision) { ThrowSuccessResponse(); } }; +class Test_TC_OCC_2_1 : public TestCommand +{ +public: + Test_TC_OCC_2_1() : TestCommand("Test_TC_OCC_2_1"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_2_1\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_2_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 : Reads mandatory attribute constrains: Occupancy\n"); + err = TestReadsMandatoryAttributeConstrainsOccupancy_0(); + break; + case 1: + ChipLogProgress(chipTool, + " ***** Test Step 1 : Writes the respective default value to mandatory attribute: Occupancy\n"); + err = TestWritesTheRespectiveDefaultValueToMandatoryAttributeOccupancy_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Reads back mandatory attribute: Occupancy\n"); + err = TestReadsBackMandatoryAttributeOccupancy_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Reads mandatory attribute constrains: OccupancySensorType\n"); + err = TestReadsMandatoryAttributeConstrainsOccupancySensorType_3(); + break; + case 4: + ChipLogProgress( + chipTool, " ***** Test Step 4 : Writes the respective default value to mandatory attribute: OccupancySensorType\n"); + err = TestWritesTheRespectiveDefaultValueToMandatoryAttributeOccupancySensorType_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Reads back mandatory attribute: OccupancySensorType\n"); + err = TestReadsBackMandatoryAttributeOccupancySensorType_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Reads mandatory attribute constrains: OccupancySensorTypeBitmap\n"); + err = TestReadsMandatoryAttributeConstrainsOccupancySensorTypeBitmap_6(); + break; + case 7: + ChipLogProgress( + chipTool, + " ***** Test Step 7 : Writes the respective default value to mandatory attribute: OccupancySensorTypeBitmap\n"); + err = TestWritesTheRespectiveDefaultValueToMandatoryAttributeOccupancySensorTypeBitmap_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Reads back mandatory attribute: OccupancySensorTypeBitmap\n"); + err = TestReadsBackMandatoryAttributeOccupancySensorTypeBitmap_8(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Callback::Callback mOnFailureCallback_0{ OnFailureCallback_0, this }; + chip::Callback::Callback mOnSuccessCallback_0{ OnSuccessCallback_0, this }; + chip::Callback::Callback mOnFailureCallback_1{ OnFailureCallback_1, this }; + chip::Callback::Callback mOnSuccessCallback_1{ OnSuccessCallback_1, this }; + chip::Callback::Callback mOnFailureCallback_2{ OnFailureCallback_2, this }; + chip::Callback::Callback mOnSuccessCallback_2{ OnSuccessCallback_2, this }; + chip::Callback::Callback mOnFailureCallback_3{ OnFailureCallback_3, this }; + chip::Callback::Callback mOnSuccessCallback_3{ OnSuccessCallback_3, + this }; + chip::Callback::Callback mOnFailureCallback_4{ OnFailureCallback_4, this }; + chip::Callback::Callback mOnSuccessCallback_4{ OnSuccessCallback_4, + this }; + chip::Callback::Callback mOnFailureCallback_5{ OnFailureCallback_5, this }; + chip::Callback::Callback mOnSuccessCallback_5{ OnSuccessCallback_5, + this }; + chip::Callback::Callback mOnFailureCallback_6{ OnFailureCallback_6, this }; + chip::Callback::Callback mOnSuccessCallback_6{ OnSuccessCallback_6, + this }; + chip::Callback::Callback mOnFailureCallback_7{ OnFailureCallback_7, this }; + chip::Callback::Callback mOnSuccessCallback_7{ OnSuccessCallback_7, + this }; + chip::Callback::Callback mOnFailureCallback_8{ OnFailureCallback_8, this }; + chip::Callback::Callback mOnSuccessCallback_8{ OnSuccessCallback_8, + this }; + + static void OnFailureCallback_0(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_0(status); + } + + static void OnSuccessCallback_0(void * context, uint8_t occupancy) + { + (static_cast(context))->OnSuccessResponse_0(occupancy); + } + + static void OnFailureCallback_1(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_1(status); + } + + static void OnSuccessCallback_1(void * context, uint8_t occupancy) + { + (static_cast(context))->OnSuccessResponse_1(occupancy); + } + + static void OnFailureCallback_2(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_2(status); + } + + static void OnSuccessCallback_2(void * context, uint8_t occupancy) + { + (static_cast(context))->OnSuccessResponse_2(occupancy); + } + + static void OnFailureCallback_3(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_3(status); + } + + static void OnSuccessCallback_3(void * context, uint8_t occupancySensorType) + { + (static_cast(context))->OnSuccessResponse_3(occupancySensorType); + } + + static void OnFailureCallback_4(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_4(status); + } + + static void OnSuccessCallback_4(void * context, uint8_t occupancySensorType) + { + (static_cast(context))->OnSuccessResponse_4(occupancySensorType); + } + + static void OnFailureCallback_5(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_5(status); + } + + static void OnSuccessCallback_5(void * context, uint8_t occupancySensorType) + { + (static_cast(context))->OnSuccessResponse_5(occupancySensorType); + } + + static void OnFailureCallback_6(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_6(status); + } + + static void OnSuccessCallback_6(void * context, uint8_t occupancySensorTypeBitmap) + { + (static_cast(context))->OnSuccessResponse_6(occupancySensorTypeBitmap); + } + + static void OnFailureCallback_7(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_7(status); + } + + static void OnSuccessCallback_7(void * context, uint8_t occupancySensorTypeBitmap) + { + (static_cast(context))->OnSuccessResponse_7(occupancySensorTypeBitmap); + } + + static void OnFailureCallback_8(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_8(status); + } + + static void OnSuccessCallback_8(void * context, uint8_t occupancySensorTypeBitmap) + { + (static_cast(context))->OnSuccessResponse_8(occupancySensorTypeBitmap); + } + + // + // Tests methods + // + + CHIP_ERROR TestReadsMandatoryAttributeConstrainsOccupancy_0() + { + chip::Controller::OccupancySensingClusterTest cluster; + cluster.Associate(mDevice, 1); + + return cluster.ReadAttributeOccupancy(mOnSuccessCallback_0.Cancel(), mOnFailureCallback_0.Cancel()); + } + + void OnFailureResponse_0(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_0(uint8_t occupancy) + { + VerifyOrReturn(CheckConstraintType("occupancy", "", "map8")); + VerifyOrReturn(CheckConstraintMaxValue("occupancy", occupancy, 1)); + NextTest(); + } + + CHIP_ERROR TestWritesTheRespectiveDefaultValueToMandatoryAttributeOccupancy_1() + { + chip::Controller::OccupancySensingClusterTest cluster; + cluster.Associate(mDevice, 1); + + uint8_t occupancyArgument = 0; + + return cluster.WriteAttributeOccupancy(mOnSuccessCallback_1.Cancel(), mOnFailureCallback_1.Cancel(), occupancyArgument); + } + + void OnFailureResponse_1(uint8_t status) { NextTest(); } + + void OnSuccessResponse_1(uint8_t occupancy) { ThrowSuccessResponse(); } + + CHIP_ERROR TestReadsBackMandatoryAttributeOccupancy_2() + { + chip::Controller::OccupancySensingClusterTest cluster; + cluster.Associate(mDevice, 1); + + return cluster.ReadAttributeOccupancy(mOnSuccessCallback_2.Cancel(), mOnFailureCallback_2.Cancel()); + } + + void OnFailureResponse_2(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_2(uint8_t occupancy) + { + VerifyOrReturn(CheckValue("occupancy", occupancy, 0)); + NextTest(); + } + + CHIP_ERROR TestReadsMandatoryAttributeConstrainsOccupancySensorType_3() + { + chip::Controller::OccupancySensingClusterTest cluster; + cluster.Associate(mDevice, 1); + + return cluster.ReadAttributeOccupancySensorType(mOnSuccessCallback_3.Cancel(), mOnFailureCallback_3.Cancel()); + } + + void OnFailureResponse_3(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_3(uint8_t occupancySensorType) + { + VerifyOrReturn(CheckConstraintType("occupancySensorType", "", "enum8")); + VerifyOrReturn(CheckConstraintMaxValue("occupancySensorType", occupancySensorType, 3)); + NextTest(); + } + + CHIP_ERROR TestWritesTheRespectiveDefaultValueToMandatoryAttributeOccupancySensorType_4() + { + chip::Controller::OccupancySensingClusterTest cluster; + cluster.Associate(mDevice, 1); + + uint8_t occupancySensorTypeArgument = static_cast(0); + + return cluster.WriteAttributeOccupancySensorType(mOnSuccessCallback_4.Cancel(), mOnFailureCallback_4.Cancel(), + occupancySensorTypeArgument); + } + + void OnFailureResponse_4(uint8_t status) { NextTest(); } + + void OnSuccessResponse_4(uint8_t occupancySensorType) { ThrowSuccessResponse(); } + + CHIP_ERROR TestReadsBackMandatoryAttributeOccupancySensorType_5() + { + chip::Controller::OccupancySensingClusterTest cluster; + cluster.Associate(mDevice, 1); + + return cluster.ReadAttributeOccupancySensorType(mOnSuccessCallback_5.Cancel(), mOnFailureCallback_5.Cancel()); + } + + void OnFailureResponse_5(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_5(uint8_t occupancySensorType) + { + VerifyOrReturn(CheckValue("occupancySensorType", occupancySensorType, 0)); + NextTest(); + } + + CHIP_ERROR TestReadsMandatoryAttributeConstrainsOccupancySensorTypeBitmap_6() + { + chip::Controller::OccupancySensingClusterTest cluster; + cluster.Associate(mDevice, 1); + + return cluster.ReadAttributeOccupancySensorTypeBitmap(mOnSuccessCallback_6.Cancel(), mOnFailureCallback_6.Cancel()); + } + + void OnFailureResponse_6(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_6(uint8_t occupancySensorTypeBitmap) + { + VerifyOrReturn(CheckConstraintType("occupancySensorTypeBitmap", "", "map8")); + VerifyOrReturn(CheckConstraintMinValue("occupancySensorTypeBitmap", occupancySensorTypeBitmap, 1)); + VerifyOrReturn(CheckConstraintMaxValue("occupancySensorTypeBitmap", occupancySensorTypeBitmap, 7)); + NextTest(); + } + + CHIP_ERROR TestWritesTheRespectiveDefaultValueToMandatoryAttributeOccupancySensorTypeBitmap_7() + { + chip::Controller::OccupancySensingClusterTest cluster; + cluster.Associate(mDevice, 1); + + uint8_t occupancySensorTypeBitmapArgument = 1; + + return cluster.WriteAttributeOccupancySensorTypeBitmap(mOnSuccessCallback_7.Cancel(), mOnFailureCallback_7.Cancel(), + occupancySensorTypeBitmapArgument); + } + + void OnFailureResponse_7(uint8_t status) { NextTest(); } + + void OnSuccessResponse_7(uint8_t occupancySensorTypeBitmap) { ThrowSuccessResponse(); } + + CHIP_ERROR TestReadsBackMandatoryAttributeOccupancySensorTypeBitmap_8() + { + chip::Controller::OccupancySensingClusterTest cluster; + cluster.Associate(mDevice, 1); + + return cluster.ReadAttributeOccupancySensorTypeBitmap(mOnSuccessCallback_8.Cancel(), mOnFailureCallback_8.Cancel()); + } + + void OnFailureResponse_8(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_8(uint8_t occupancySensorTypeBitmap) + { + VerifyOrReturn(CheckValue("occupancySensorTypeBitmap", occupancySensorTypeBitmap, 1)); + NextTest(); + } +}; + class Test_TC_OO_1_1 : public TestCommand { public: @@ -13675,10 +14022,10 @@ class Test_TC_PCC_2_1 : public TestCommand } }; -class Test_TC_RH_1_1 : public TestCommand +class Test_TC_PCC_2_2 : public TestCommand { public: - Test_TC_RH_1_1() : TestCommand("Test_TC_RH_1_1"), mTestIndex(0) {} + Test_TC_PCC_2_2() : TestCommand("Test_TC_PCC_2_2"), mTestIndex(0) {} /////////// TestCommand Interface ///////// void NextTest() override @@ -13687,12 +14034,12 @@ class Test_TC_RH_1_1 : public TestCommand if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RH_1_1\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_2\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RH_1_1\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_2\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -13706,9 +14053,16 @@ class Test_TC_RH_1_1 : public TestCommand switch (mTestIndex++) { case 0: - ChipLogProgress(chipTool, - " ***** Test Step 0 : write the default values to mandatory global attribute: ClusterRevision\n"); - err = TestWriteTheDefaultValuesToMandatoryGlobalAttributeClusterRevision_0(); + ChipLogProgress(chipTool, " ***** Test Step 0 : Write 1 to the OperationMode attribute to DUT: OperationMode\n"); + err = TestWrite1ToTheOperationModeAttributeToDutOperationMode_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Write 2 to the OperationMode attribute to DUT: OperationMode\n"); + err = TestWrite2ToTheOperationModeAttributeToDutOperationMode_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Write 3 to the OperationMode attribute to DUT: OperationMode\n"); + err = TestWrite3ToTheOperationModeAttributeToDutOperationMode_2(); break; } @@ -13721,7 +14075,255 @@ class Test_TC_RH_1_1 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 1; + const uint16_t mTestCount = 3; + + chip::Callback::Callback mOnFailureCallback_0{ OnFailureCallback_0, this }; + chip::Callback::Callback mOnSuccessCallback_0{ OnSuccessCallback_0, this }; + chip::Callback::Callback mOnFailureCallback_1{ OnFailureCallback_1, this }; + chip::Callback::Callback mOnSuccessCallback_1{ OnSuccessCallback_1, this }; + chip::Callback::Callback mOnFailureCallback_2{ OnFailureCallback_2, this }; + chip::Callback::Callback mOnSuccessCallback_2{ OnSuccessCallback_2, this }; + + static void OnFailureCallback_0(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_0(status); + } + + static void OnSuccessCallback_0(void * context, uint8_t operationMode) + { + (static_cast(context))->OnSuccessResponse_0(operationMode); + } + + static void OnFailureCallback_1(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_1(status); + } + + static void OnSuccessCallback_1(void * context, uint8_t operationMode) + { + (static_cast(context))->OnSuccessResponse_1(operationMode); + } + + static void OnFailureCallback_2(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_2(status); + } + + static void OnSuccessCallback_2(void * context, uint8_t operationMode) + { + (static_cast(context))->OnSuccessResponse_2(operationMode); + } + + // + // Tests methods + // + + CHIP_ERROR TestWrite1ToTheOperationModeAttributeToDutOperationMode_0() + { + chip::Controller::PumpConfigurationAndControlClusterTest cluster; + cluster.Associate(mDevice, 1); + + uint8_t operationModeArgument = static_cast(1); + + return cluster.WriteAttributeOperationMode(mOnSuccessCallback_0.Cancel(), mOnFailureCallback_0.Cancel(), + operationModeArgument); + } + + void OnFailureResponse_0(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_0(uint8_t operationMode) { NextTest(); } + + CHIP_ERROR TestWrite2ToTheOperationModeAttributeToDutOperationMode_1() + { + chip::Controller::PumpConfigurationAndControlClusterTest cluster; + cluster.Associate(mDevice, 1); + + uint8_t operationModeArgument = static_cast(2); + + return cluster.WriteAttributeOperationMode(mOnSuccessCallback_1.Cancel(), mOnFailureCallback_1.Cancel(), + operationModeArgument); + } + + void OnFailureResponse_1(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_1(uint8_t operationMode) { NextTest(); } + + CHIP_ERROR TestWrite3ToTheOperationModeAttributeToDutOperationMode_2() + { + chip::Controller::PumpConfigurationAndControlClusterTest cluster; + cluster.Associate(mDevice, 1); + + uint8_t operationModeArgument = static_cast(3); + + return cluster.WriteAttributeOperationMode(mOnSuccessCallback_2.Cancel(), mOnFailureCallback_2.Cancel(), + operationModeArgument); + } + + void OnFailureResponse_2(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_2(uint8_t operationMode) { NextTest(); } +}; + +class Test_TC_PCC_2_3 : public TestCommand +{ +public: + Test_TC_PCC_2_3() : TestCommand("Test_TC_PCC_2_3"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_3\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_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 : Write 0 to the OperationMode attribute to DUT\n"); + err = TestWrite0ToTheOperationModeAttributeToDut_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Reads the attribute: EffectiveOperationMode\n"); + err = TestReadsTheAttributeEffectiveOperationMode_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Callback::Callback mOnFailureCallback_0{ OnFailureCallback_0, this }; + chip::Callback::Callback mOnSuccessCallback_0{ OnSuccessCallback_0, this }; + chip::Callback::Callback mOnFailureCallback_1{ OnFailureCallback_1, this }; + chip::Callback::Callback mOnSuccessCallback_1{ OnSuccessCallback_1, + this }; + + static void OnFailureCallback_0(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_0(status); + } + + static void OnSuccessCallback_0(void * context, uint8_t operationMode) + { + (static_cast(context))->OnSuccessResponse_0(operationMode); + } + + static void OnFailureCallback_1(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_1(status); + } + + static void OnSuccessCallback_1(void * context, uint8_t effectiveOperationMode) + { + (static_cast(context))->OnSuccessResponse_1(effectiveOperationMode); + } + + // + // Tests methods + // + + CHIP_ERROR TestWrite0ToTheOperationModeAttributeToDut_0() + { + chip::Controller::PumpConfigurationAndControlClusterTest cluster; + cluster.Associate(mDevice, 1); + + uint8_t operationModeArgument = static_cast(0); + + return cluster.WriteAttributeOperationMode(mOnSuccessCallback_0.Cancel(), mOnFailureCallback_0.Cancel(), + operationModeArgument); + } + + void OnFailureResponse_0(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_0(uint8_t operationMode) { NextTest(); } + + CHIP_ERROR TestReadsTheAttributeEffectiveOperationMode_1() + { + chip::Controller::PumpConfigurationAndControlClusterTest cluster; + cluster.Associate(mDevice, 1); + + return cluster.ReadAttributeEffectiveOperationMode(mOnSuccessCallback_1.Cancel(), mOnFailureCallback_1.Cancel()); + } + + void OnFailureResponse_1(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_1(uint8_t effectiveOperationMode) + { + VerifyOrReturn(CheckValue("effectiveOperationMode", effectiveOperationMode, 0)); + NextTest(); + } +}; + +class Test_TC_RH_1_1 : public TestCommand +{ +public: + Test_TC_RH_1_1() : TestCommand("Test_TC_RH_1_1"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_RH_1_1\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RH_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 : write the default values to mandatory global attribute: ClusterRevision\n"); + err = TestWriteTheDefaultValuesToMandatoryGlobalAttributeClusterRevision_0(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 1; chip::Callback::Callback mOnFailureCallback_0{ OnFailureCallback_0, this }; chip::Callback::Callback mOnSuccessCallback_0{ OnSuccessCallback_0, this }; @@ -13756,6 +14358,120 @@ class Test_TC_RH_1_1 : public TestCommand void OnSuccessResponse_0(uint16_t clusterRevision) { ThrowSuccessResponse(); } }; +class Test_TC_RH_2_1 : public TestCommand +{ +public: + Test_TC_RH_2_1() : TestCommand("Test_TC_RH_2_1"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_RH_2_1\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RH_2_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 : Reads constraints of attribute: MeasuredValue\n"); + err = TestReadsConstraintsOfAttributeMeasuredValue_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Reads constraints of attribute: MinMeasuredValue\n"); + err = TestReadsConstraintsOfAttributeMinMeasuredValue_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Callback::Callback mOnFailureCallback_0{ OnFailureCallback_0, this }; + chip::Callback::Callback mOnSuccessCallback_0{ OnSuccessCallback_0, this }; + chip::Callback::Callback mOnFailureCallback_1{ OnFailureCallback_1, this }; + chip::Callback::Callback mOnSuccessCallback_1{ OnSuccessCallback_1, this }; + + static void OnFailureCallback_0(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_0(status); + } + + static void OnSuccessCallback_0(void * context, uint16_t measuredValue) + { + (static_cast(context))->OnSuccessResponse_0(measuredValue); + } + + static void OnFailureCallback_1(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_1(status); + } + + static void OnSuccessCallback_1(void * context, uint16_t minMeasuredValue) + { + (static_cast(context))->OnSuccessResponse_1(minMeasuredValue); + } + + // + // Tests methods + // + + CHIP_ERROR TestReadsConstraintsOfAttributeMeasuredValue_0() + { + chip::Controller::RelativeHumidityMeasurementClusterTest cluster; + cluster.Associate(mDevice, 1); + + return cluster.ReadAttributeMeasuredValue(mOnSuccessCallback_0.Cancel(), mOnFailureCallback_0.Cancel()); + } + + void OnFailureResponse_0(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_0(uint16_t measuredValue) + { + VerifyOrReturn(CheckConstraintType("measuredValue", "", "uint16")); + NextTest(); + } + + CHIP_ERROR TestReadsConstraintsOfAttributeMinMeasuredValue_1() + { + chip::Controller::RelativeHumidityMeasurementClusterTest cluster; + cluster.Associate(mDevice, 1); + + return cluster.ReadAttributeMinMeasuredValue(mOnSuccessCallback_1.Cancel(), mOnFailureCallback_1.Cancel()); + } + + void OnFailureResponse_1(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_1(uint16_t minMeasuredValue) + { + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "", "uint16")); + VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", minMeasuredValue, 9999)); + NextTest(); + } +}; + class Test_TC_TM_1_1 : public TestCommand { public: @@ -23247,12 +23963,16 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), make_unique(), make_unique(), + make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(),