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 75dee5938181b3..e10f737153cfd1 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -27154,15 +27154,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(); @@ -27170,7 +27199,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); @@ -27179,9 +27208,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(); @@ -27189,7 +27275,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); @@ -27198,9 +27284,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(); @@ -27208,7 +27337,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); @@ -27222,6 +27351,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 {