From 3ab93c338bcc66d7849cb50d69cb51bbd95c50bf Mon Sep 17 00:00:00 2001 From: Jonathan Megevand Date: Fri, 28 Jan 2022 13:42:27 +0100 Subject: [PATCH] TEST: YAML update WNCV 3.3 StopMotion --- .../certification/Test_TC_WNCV_3_3.yaml | 133 +++-- .../Framework/CHIPTests/CHIPClustersTests.m | 287 ++++++++++- .../chip-tool/zap-generated/test/Commands.h | 471 +++++++++++++++++- 3 files changed, 822 insertions(+), 69 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_WNCV_3_3.yaml b/src/app/tests/suites/certification/Test_TC_WNCV_3_3.yaml index 753f21cbb0bd9e..c812b66556b178 100644 --- a/src/app/tests/suites/certification/Test_TC_WNCV_3_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_WNCV_3_3.yaml @@ -21,71 +21,136 @@ config: endpoint: 1 tests: - - label: "Wait for the commissioned device to be retrieved" + - label: "0: Wait for the commissioned device to be retrieved" cluster: "DelayCommands" command: "WaitForCommissionee" - ### Step 1x -> Initialize Position - ### MANDATORY Command - - label: "1a: TH adjusts the the DUT to a non-open position" + ################ Position Init Phase ############# + ### Step 1x -> Initialize the Covering position before any testing + ### MANDATORY Init Commands + - label: "1a: TH sends DownOrClose command to preposition the DUT in the opposite direction" + command: "DownOrClose" + + - label: "1b: TH Waits for 6-8 seconds movement(s) on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 6000 + + - label: "1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction" command: "UpOrOpen" - ### Depends on a sleep/wait command how to do this with a real device - - label: "1b: Wait for the movement to start and go on for a few seconds" - disabled: true + - label: "1d: TH Waits for 2 seconds movement(s) on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 2000 + + ######## StopMotion Command ####### + ### Step 2x -> Check StopMotion fast effects + ### Before subscribe to reports + - label: "2: Subscribe to DUT reports on OperationalStatus attribute" + command: "subscribeAttribute" + attribute: "OperationalStatus" + minInterval: 4 + maxInterval: 5 + response: + constraints: + type: map8 - ### Step 2x -> Check Command instant effects + longer effects ### MANDATORY Command - - label: "2a: TH sends StopMotion command to DUT" + - label: "2a: TH sends a StopMotion command to DUT" command: "StopMotion" + ### DUT Slow down and stop + - label: "2b: TH waits for 3 seconds the end of inertial movement(s) on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 3000 + + ### Must Be ZERO + # The value of bit 0..1 must be 00b & if (LF) value of bit 2..3 must be 00b & if (TL) value of bit 4..5 must be 00b + - label: "2c: Verify DUT reports OperationalStatus attribute to TH after a StopMotion" + command: "waitForReport" + attribute: "OperationalStatus" + response: + value: 0 + + ### DUT updates its attributes + - label: "2d: TH waits for 100-1000ms attributes update on the device" + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 1000 + ### MANDATORY reads - - label: "2b: TH reads OperationalStatus attribute from DUT" + - label: "2e: TH reads OperationalStatus attribute from DUT" command: "readAttribute" attribute: "OperationalStatus" response: value: 0 - ### 2c Check equality with a tolerance between Target & Current for Lift - ### Depends on the FeatureMap + ######## StopMotion w/ Lift ####### + ### Step 3x -> Verify StopMotion longer period effects on Lift + ### Mandatory/Optionality Depends on (PA & LF) for all 4x Steps + + ### Read Current Position -> Store this value for step 4c - label: - "2c-1: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute + "3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" - attribute: "TargetPositionLiftPercent100ths" + attribute: "CurrentPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: + saveAs: attrCurrentPositionLift constraints: - type: uint16 + minValue: 0 + maxValue: 10000 + ### Read Target Position -> Compare this value w/ Current + ### Shall be tested as equals CurrentPositionLiftPercent100ths - label: - "2c-2: If (PA & LF) TH reads CurrentPositionLiftPercent100ths - attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value + "3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute + 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT" command: "readAttribute" - attribute: "CurrentPositionLiftPercent100ths" + attribute: "TargetPositionLiftPercent100ths" + PICS: WNCV_LF && WNCV_PA_LF response: - constraints: - type: uint16 + value: attrCurrentPositionLift + + ######## StopMotion w/ Tilt ####### + ### Step 4x -> Verify StopMotion longer period effects on Tilt + ### Mandatory/Optionality Depends on (PA & TL) for all 4x Steps - ### 2d Check equality with a tolerance between Target & Current for Tilt - ### Depends on the FeatureMap + ### Read Current Position -> Store this value for step 4c - label: - "2d-1: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute + "4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value command: "readAttribute" - attribute: "TargetPositionTiltPercent100ths" + attribute: "CurrentPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL response: + saveAs: attrCurrentPositionTilt constraints: - type: uint16 + minValue: 0 + maxValue: 10000 + ### Read Target Position -> Compare this value w/ Current + ### Shall be tested as equals CurrentPositionTiltPercent100ths - label: - "2d-2: If (PA & TL) TH reads CurrentPositionTiltPercent100ths - attribute from DUT" - disabled: true # Step applied conditionnally with an !expected response value + "4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute + 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT" command: "readAttribute" - attribute: "CurrentPositionTiltPercent100ths" + attribute: "TargetPositionTiltPercent100ths" + PICS: WNCV_TL && WNCV_PA_TL response: - constraints: - type: uint16 + value: attrCurrentPositionTilt diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 287cb49beda635..220d41acdd67c1 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -26336,15 +26336,44 @@ - (void)testSendClusterTest_TC_WNCV_3_2_000024_ReadAttribute - (void)testSendClusterTest_TC_WNCV_3_3_000000_WaitForCommissionee { - XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + XCTestExpectation * expectation = [self expectationWithDescription:@"0: Wait for the commissioned device to be retrieved"]; dispatch_queue_t queue = dispatch_get_main_queue(); WaitForCommissionee(expectation, queue); [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_3_000001_UpOrOpen +- (void)testSendClusterTest_TC_WNCV_3_3_000001_DownOrClose +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1a: TH sends DownOrClose command to preposition the DUT in the opposite direction"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster downOrCloseWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"1a: TH sends DownOrClose command to preposition the DUT in the opposite direction Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000002_WaitForMs { - XCTestExpectation * expectation = [self expectationWithDescription:@"1a: TH adjusts the the DUT to a non-open position"]; + XCTestExpectation * expectation = [self expectationWithDescription:@"1b: TH Waits for 6-8 seconds movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 6000); + [self waitForExpectationsWithTimeout:(6000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000003_UpOrOpen +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); @@ -26352,7 +26381,7 @@ - (void)testSendClusterTest_TC_WNCV_3_3_000001_UpOrOpen XCTAssertNotNil(cluster); [cluster upOrOpenWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"1a: TH adjusts the the DUT to a non-open position Error: %@", err); + NSLog(@"1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); @@ -26361,9 +26390,66 @@ - (void)testSendClusterTest_TC_WNCV_3_3_000001_UpOrOpen [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_3_000002_StopMotion +- (void)testSendClusterTest_TC_WNCV_3_3_000004_WaitForMs +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"1d: TH Waits for 2 seconds movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 2000); + [self waitForExpectationsWithTimeout:(2000 / 1000) + kTimeoutInSeconds handler:nil]; +} +bool testSendClusterTest_TC_WNCV_3_3_000005_WaitForReport_Fulfilled = false; +ResponseHandler test_Test_TC_WNCV_3_3_OperationalStatus_Reported = nil; +- (void)testSendClusterTest_TC_WNCV_3_3_000005_WaitForReport +{ + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + test_Test_TC_WNCV_3_3_OperationalStatus_Reported = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Report: 2: Subscribe to DUT reports on OperationalStatus attribute Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + testSendClusterTest_TC_WNCV_3_3_000005_WaitForReport_Fulfilled = true; + }; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000006_SubscribeAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"2: Subscribe to DUT reports on OperationalStatus attribute"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + uint16_t minIntervalArgument = 4U; + uint16_t maxIntervalArgument = 5U; + [cluster subscribeAttributeOperationalStatusWithMinInterval:minIntervalArgument + maxInterval:maxIntervalArgument + subscriptionEstablished:^{ + XCTAssertEqual(testSendClusterTest_TC_WNCV_3_3_000005_WaitForReport_Fulfilled, true); + [expectation fulfill]; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"2: Subscribe to DUT reports on OperationalStatus attribute Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + if (test_Test_TC_WNCV_3_3_OperationalStatus_Reported != nil) { + ResponseHandler callback = test_Test_TC_WNCV_3_3_OperationalStatus_Reported; + test_Test_TC_WNCV_3_3_OperationalStatus_Reported = nil; + callback(value, err); + } + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000007_StopMotion { - XCTestExpectation * expectation = [self expectationWithDescription:@"2a: TH sends StopMotion command to DUT"]; + XCTestExpectation * expectation = [self expectationWithDescription:@"2a: TH sends a StopMotion command to DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); @@ -26371,7 +26457,7 @@ - (void)testSendClusterTest_TC_WNCV_3_3_000002_StopMotion XCTAssertNotNil(cluster); [cluster stopMotionWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"2a: TH sends StopMotion command to DUT Error: %@", err); + NSLog(@"2a: TH sends a StopMotion command to DUT Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); @@ -26380,9 +26466,52 @@ - (void)testSendClusterTest_TC_WNCV_3_3_000002_StopMotion [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_WNCV_3_3_000003_ReadAttribute +- (void)testSendClusterTest_TC_WNCV_3_3_000008_WaitForMs +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"2b: TH waits for 3 seconds the end of inertial movement(s) on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 3000); + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000009_WaitForReport { - XCTestExpectation * expectation = [self expectationWithDescription:@"2b: TH reads OperationalStatus attribute from DUT"]; + XCTestExpectation * expectation = + [self expectationWithDescription:@"2c: Verify DUT reports OperationalStatus attribute to TH after a StopMotion"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + test_Test_TC_WNCV_3_3_OperationalStatus_Reported = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"2c: Verify DUT reports OperationalStatus attribute to TH after a StopMotion Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertEqual([actualValue unsignedCharValue], 0); + } + + [expectation fulfill]; + }; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000010_WaitForMs +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"2d: TH waits for 100-1000ms attributes update on the device"]; + + dispatch_queue_t queue = dispatch_get_main_queue(); + WaitForMs(expectation, queue, 1000); + [self waitForExpectationsWithTimeout:(1000 / 1000) + kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000011_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"2e: TH reads OperationalStatus attribute from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); @@ -26390,7 +26519,7 @@ - (void)testSendClusterTest_TC_WNCV_3_3_000003_ReadAttribute XCTAssertNotNil(cluster); [cluster readAttributeOperationalStatusWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"2b: TH reads OperationalStatus attribute from DUT Error: %@", err); + NSLog(@"2e: TH reads OperationalStatus attribute from DUT Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); @@ -26404,6 +26533,144 @@ - (void)testSendClusterTest_TC_WNCV_3_3_000003_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +uint16_t attrCurrentPositionLift; +- (void)testSendClusterTest_TC_WNCV_3_3_000012_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + { + id actualValue = value; + attrCurrentPositionLift = [actualValue unsignedShortValue]; + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000013_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be " + @"equal with CurrentPositionLiftPercent100ths from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeTargetPositionLiftPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with " + @"CurrentPositionLiftPercent100ths from DUT Error: %@", + err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertFalse(actualValue == nil); + XCTAssertEqual([actualValue unsignedShortValue], attrCurrentPositionLift); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +uint16_t attrCurrentPositionTilt; +- (void)testSendClusterTest_TC_WNCV_3_3_000014_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeCurrentPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedShortValue], 0U); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedShortValue], 10000U); + } + } + { + id actualValue = value; + attrCurrentPositionTilt = [actualValue unsignedShortValue]; + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_3_3_000015_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be " + @"equal with CurrentPositionTiltPercent100ths from DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster + readAttributeTargetPositionTiltPercent100thsWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with " + @"CurrentPositionTiltPercent100ths from DUT Error: %@", + err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + { + id actualValue = value; + XCTAssertFalse(actualValue == nil); + XCTAssertEqual([actualValue unsignedShortValue], attrCurrentPositionTilt); + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} - (void)testSendClusterTestCluster_000000_WaitForCommissionee { diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index e35fc59b579285..cf174e8b6025d0 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -44505,20 +44505,101 @@ class Test_TC_WNCV_3_3 : public TestCommand switch (mTestIndex++) { case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + ChipLogProgress(chipTool, " ***** Test Step 0 : 0: Wait for the commissioned device to be retrieved\n"); + err = Test0WaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : 1a: TH adjusts the the DUT to a non-open position\n"); - err = Test1aThAdjustsTheTheDutToANonOpenPosition_1(); + ChipLogProgress( + chipTool, + " ***** Test Step 1 : 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); + err = Test1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : 2a: TH sends StopMotion command to DUT\n"); - err = Test2aThSendsStopMotionCommandToDut_2(); + ChipLogProgress(chipTool, " ***** Test Step 2 : 1b: TH Waits for 6-8 seconds movement(s) on the device\n"); + err = Test1bThWaitsFor68SecondsMovementsOnTheDevice_2(); break; case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : 2b: TH reads OperationalStatus attribute from DUT\n"); - err = Test2bThReadsOperationalStatusAttributeFromDut_3(); + ChipLogProgress( + chipTool, " ***** Test Step 3 : 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); + err = Test1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : 1d: TH Waits for 2 seconds movement(s) on the device\n"); + err = Test1dThWaitsFor2SecondsMovementsOnTheDevice_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Report: 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = TestReport2SubscribeToDutReportsOnOperationalStatusAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = Test2SubscribeToDutReportsOnOperationalStatusAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : 2a: TH sends a StopMotion command to DUT\n"); + err = Test2aThSendsAStopMotionCommandToDut_7(); + break; + case 8: + ChipLogProgress(chipTool, + " ***** Test Step 8 : 2b: TH waits for 3 seconds the end of inertial movement(s) on the device\n"); + err = Test2bThWaitsFor3SecondsTheEndOfInertialMovementsOnTheDevice_8(); + break; + case 9: + ChipLogProgress(chipTool, + " ***** Test Step 9 : 2c: Verify DUT reports OperationalStatus attribute to TH after a StopMotion\n"); + err = Test2cVerifyDutReportsOperationalStatusAttributeToThAfterAStopMotion_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : 2d: TH waits for 100-1000ms attributes update on the device\n"); + err = Test2dThWaitsFor1001000msAttributesUpdateOnTheDevice_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : 2e: TH reads OperationalStatus attribute from DUT\n"); + err = Test2eThReadsOperationalStatusAttributeFromDut_11(); + break; + case 12: + ChipLogProgress( + chipTool, " ***** Test Step 12 : 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = Test3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, + " ***** Test Step 13 : 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must " + "be equal with CurrentPositionLiftPercent100ths from DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF")) + { + NextTest(); + return; + } + err = + Test3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_13(); + break; + case 14: + ChipLogProgress( + chipTool, " ***** Test Step 14 : 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = Test4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, + " ***** Test Step 15 : 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must " + "be equal with CurrentPositionTiltPercent100ths from DUT\n"); + if (ShouldSkip("WNCV_TL && WNCV_PA_TL")) + { + NextTest(); + return; + } + err = + Test4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_15(); break; } @@ -44531,35 +44612,124 @@ class Test_TC_WNCV_3_3 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; + const uint16_t mTestCount = 16; chip::Optional mCluster; chip::Optional mEndpoint; - static void OnFailureCallback_3(void * context, CHIP_ERROR error) + chip::Percent100ths attrCurrentPositionLift; + chip::Percent100ths attrCurrentPositionTilt; + + typedef void (*Test_Test_TC_WNCV_3_3_OperationalStatus_ReportCallback)(void * context, uint8_t value); + Test_Test_TC_WNCV_3_3_OperationalStatus_ReportCallback mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported = nullptr; + + static void OnFailureCallback_5(void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_3(error); + (static_cast(context))->OnFailureResponse_5(error); } - static void OnSuccessCallback_3(void * context, uint8_t operationalStatus) + static void OnSuccessCallback_5(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_5(operationalStatus); + } + + bool mReceivedReport_5 = false; + + static void OnFailureCallback_6(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_6(error); + } + + static void OnSuccessCallback_6(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_6(operationalStatus); + } + + static void OnSubscriptionEstablished_6(void * context) + { + (static_cast(context))->OnSubscriptionEstablishedResponse_6(); + } + + static void OnFailureCallback_9(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_9(error); + } + + static void OnSuccessCallback_9(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_9(operationalStatus); + } + + bool mReceivedReport_9 = false; + + static void OnFailureCallback_11(void * context, CHIP_ERROR error) { - (static_cast(context))->OnSuccessResponse_3(operationalStatus); + (static_cast(context))->OnFailureResponse_11(error); + } + + static void OnSuccessCallback_11(void * context, uint8_t operationalStatus) + { + (static_cast(context))->OnSuccessResponse_11(operationalStatus); + } + + static void OnFailureCallback_12(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_12(error); + } + + static void OnSuccessCallback_12(void * context, + const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_12(currentPositionLiftPercent100ths); + } + + static void OnFailureCallback_13(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_13(error); + } + + static void OnSuccessCallback_13(void * context, + const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + (static_cast(context))->OnSuccessResponse_13(targetPositionLiftPercent100ths); + } + + static void OnFailureCallback_14(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_14(error); + } + + static void OnSuccessCallback_14(void * context, + const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + (static_cast(context))->OnSuccessResponse_14(currentPositionTiltPercent100ths); + } + + static void OnFailureCallback_15(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_15(error); + } + + static void OnSuccessCallback_15(void * context, + const chip::app::DataModel::Nullable & targetPositionTiltPercent100ths) + { + (static_cast(context))->OnSuccessResponse_15(targetPositionTiltPercent100ths); } // // Tests methods // - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + CHIP_ERROR Test0WaitForTheCommissionedDeviceToBeRetrieved_0() { SetIdentity(kIdentityAlpha); return WaitForCommissionee(); } - CHIP_ERROR Test1aThAdjustsTheTheDutToANonOpenPosition_1() + CHIP_ERROR Test1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type; + using RequestType = chip::app::Clusters::WindowCovering::Commands::DownOrClose::Type; RequestType request; @@ -44583,7 +44753,109 @@ class Test_TC_WNCV_3_3 : public TestCommand void OnSuccessResponse_1() { NextTest(); } - CHIP_ERROR Test2aThSendsStopMotionCommandToDut_2() + CHIP_ERROR Test1bThWaitsFor68SecondsMovementsOnTheDevice_2() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(6000); + } + + CHIP_ERROR Test1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_3(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_3(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_3(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_3() { NextTest(); } + + CHIP_ERROR Test1dThWaitsFor2SecondsMovementsOnTheDevice_4() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(2000); + } + + CHIP_ERROR TestReport2SubscribeToDutReportsOnOperationalStatusAttribute_5() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported = OnSuccessCallback_5; + return WaitForMs(0); + } + + void OnFailureResponse_5(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_5(uint8_t operationalStatus) + { + mReceivedReport_5 = true; + + VerifyOrReturn(CheckConstraintType("operationalStatus", "", "map8")); + } + + CHIP_ERROR Test2SubscribeToDutReportsOnOperationalStatusAttribute_6() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + uint16_t minIntervalArgument; + minIntervalArgument = 4U; + uint16_t maxIntervalArgument; + maxIntervalArgument = 5U; + + ReturnErrorOnFailure( + cluster.SubscribeAttribute( + this, OnSuccessCallback_6, OnFailureCallback_6, minIntervalArgument, maxIntervalArgument, + OnSubscriptionEstablished_6)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_6(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_6(uint8_t value) + { + if (mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported) + { + auto callback = mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported; + mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported = nullptr; + callback(this, value); + } + } + + void OnSubscriptionEstablishedResponse_6() + { + VerifyOrReturn(mReceivedReport_5, Exit("Initial report not received!")); + NextTest(); + } + + CHIP_ERROR Test2aThSendsAStopMotionCommandToDut_7() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; using RequestType = chip::app::Clusters::WindowCovering::Commands::StopMotion::Type; @@ -44591,48 +44863,197 @@ class Test_TC_WNCV_3_3 : public TestCommand RequestType request; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_2(); + (static_cast(context))->OnSuccessResponse_7(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_2(error); + (static_cast(context))->OnFailureResponse_7(error); }; ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_2(CHIP_ERROR error) + void OnFailureResponse_7(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_2() { NextTest(); } + void OnSuccessResponse_7() { NextTest(); } - CHIP_ERROR Test2bThReadsOperationalStatusAttributeFromDut_3() + CHIP_ERROR Test2bThWaitsFor3SecondsTheEndOfInertialMovementsOnTheDevice_8() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(3000); + } + + CHIP_ERROR Test2cVerifyDutReportsOperationalStatusAttributeToThAfterAStopMotion_9() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + mTest_Test_TC_WNCV_3_3_OperationalStatus_Reported = OnSuccessCallback_9; + return CHIP_NO_ERROR; + } + + void OnFailureResponse_9(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_9(uint8_t operationalStatus) + { + mReceivedReport_9 = true; + + VerifyOrReturn(CheckValue("operationalStatus", operationalStatus, 0)); + + NextTest(); + } + + CHIP_ERROR Test2dThWaitsFor1001000msAttributesUpdateOnTheDevice_10() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); + } + + CHIP_ERROR Test2eThReadsOperationalStatusAttributeFromDut_11() { const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; chip::Controller::WindowCoveringClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_3, OnFailureCallback_3)); + this, OnSuccessCallback_11, OnFailureCallback_11)); return CHIP_NO_ERROR; } - void OnFailureResponse_3(CHIP_ERROR error) + void OnFailureResponse_11(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_3(uint8_t operationalStatus) + void OnSuccessResponse_11(uint8_t operationalStatus) { VerifyOrReturn(CheckValue("operationalStatus", operationalStatus, 0)); NextTest(); } + + CHIP_ERROR Test3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_12() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_12, OnFailureCallback_12)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_12(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_12(const chip::app::DataModel::Nullable & currentPositionLiftPercent100ths) + { + VerifyOrReturn( + CheckConstraintMinValue("currentPositionLiftPercent100ths", currentPositionLiftPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", + currentPositionLiftPercent100ths, 10000U)); + attrCurrentPositionLift = currentPositionLiftPercent100ths; + NextTest(); + } + + CHIP_ERROR + Test3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_13() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_13, OnFailureCallback_13)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_13(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_13(const chip::app::DataModel::Nullable & targetPositionLiftPercent100ths) + { + VerifyOrReturn(CheckValueNonNull("targetPositionLiftPercent100ths", targetPositionLiftPercent100ths)); + VerifyOrReturn(CheckValue("targetPositionLiftPercent100ths.Value()", targetPositionLiftPercent100ths.Value(), + attrCurrentPositionLift)); + + NextTest(); + } + + CHIP_ERROR Test4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_14() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_14, OnFailureCallback_14)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_14(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_14(const chip::app::DataModel::Nullable & currentPositionTiltPercent100ths) + { + VerifyOrReturn( + CheckConstraintMinValue("currentPositionTiltPercent100ths", currentPositionTiltPercent100ths, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", + currentPositionTiltPercent100ths, 10000U)); + attrCurrentPositionTilt = currentPositionTiltPercent100ths; + NextTest(); + } + + CHIP_ERROR + Test4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_15() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::WindowCoveringClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure( + cluster.ReadAttribute( + this, OnSuccessCallback_15, OnFailureCallback_15)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_15(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_15(const chip::app::DataModel::Nullable & targetPositionTiltPercent100ths) + { + VerifyOrReturn(CheckValueNonNull("targetPositionTiltPercent100ths", targetPositionTiltPercent100ths)); + VerifyOrReturn(CheckValue("targetPositionTiltPercent100ths.Value()", targetPositionTiltPercent100ths.Value(), + attrCurrentPositionTilt)); + + NextTest(); + } }; class TV_TargetNavigatorCluster : public TestCommand