From 40b7c61a1681a50e9f03e263385ec38bdbd67ae3 Mon Sep 17 00:00:00 2001 From: Jonathan Megevand Date: Wed, 2 Feb 2022 17:20:51 +0100 Subject: [PATCH] TEST: YAML enable test on WNCV 3.3 - issue #14502 fixes by PR# 14602 --- .../certification/Test_TC_WNCV_3_3.yaml | 6 - .../Framework/CHIPTests/CHIPClustersTests.m | 146 ++++++++++++ .../chip-tool/zap-generated/test/Commands.h | 219 +++++++++++++++++- .../zap-generated/endpoint_config.h | 7 +- .../zap-generated/endpoint_config.h | 8 +- 5 files changed, 373 insertions(+), 13 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 6b54f1b78fc367..651420e8e5126e 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 @@ -111,13 +111,10 @@ tests: ### Step 3x -> Verify StopMotion longer period effects on Lift ### Mandatory/Optionality Depends on (PA & LF) for all 4x Steps - # TODO Remove disabled once issue 14502 is fixed - ### Read Current Position -> Store this value for step 4c - label: "3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT" - disabled: true command: "readAttribute" attribute: "CurrentPositionLiftPercent100ths" PICS: WNCV_LF && WNCV_PA_LF @@ -132,7 +129,6 @@ tests: - label: "3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT" - disabled: true command: "readAttribute" attribute: "TargetPositionLiftPercent100ths" PICS: WNCV_LF && WNCV_PA_LF @@ -147,7 +143,6 @@ tests: - label: "4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT" - disabled: true command: "readAttribute" attribute: "CurrentPositionTiltPercent100ths" PICS: WNCV_TL && WNCV_PA_TL @@ -162,7 +157,6 @@ tests: - label: "4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT" - disabled: true command: "readAttribute" attribute: "TargetPositionTiltPercent100ths" PICS: WNCV_TL && WNCV_PA_TL diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 004db8ea654379..ee38cc4726e976 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -27417,6 +27417,152 @@ - (void)testSendClusterTest_TC_WNCV_3_3_000011_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +NSNumber * _Nullable 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; + } + + [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; + if (attrCurrentPositionLift == nil) { + XCTAssertTrue(actualValue == nil); + } else { + XCTAssertFalse(actualValue == nil); + XCTAssertEqualObjects(actualValue, attrCurrentPositionLift); + } + } + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +NSNumber * _Nullable 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; + } + + [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; + if (attrCurrentPositionTilt == nil) { + XCTAssertTrue(actualValue == nil); + } else { + XCTAssertFalse(actualValue == nil); + XCTAssertEqualObjects(actualValue, 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 ca02241dd2ee1f..694ba0ac53f01f 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -47252,6 +47252,50 @@ class Test_TC_WNCV_3_3 : public TestCommand 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; } if (CHIP_NO_ERROR != err) @@ -47263,11 +47307,14 @@ class Test_TC_WNCV_3_3 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; + const uint16_t mTestCount = 16; chip::Optional mCluster; chip::Optional mEndpoint; + chip::app::DataModel::Nullable attrCurrentPositionLift; + chip::app::DataModel::Nullable 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; @@ -47320,6 +47367,50 @@ class Test_TC_WNCV_3_3 : public TestCommand (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 // @@ -47546,6 +47637,132 @@ class Test_TC_WNCV_3_3 : public TestCommand 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) + { + if (attrCurrentPositionLift.IsNull()) + { + VerifyOrReturn(CheckValueNull("targetPositionLiftPercent100ths", targetPositionLiftPercent100ths)); + } + else + { + VerifyOrReturn(CheckValueNonNull("targetPositionLiftPercent100ths", targetPositionLiftPercent100ths)); + VerifyOrReturn(CheckValue("targetPositionLiftPercent100ths.Value()", targetPositionLiftPercent100ths.Value(), + attrCurrentPositionLift.Value())); + } + + 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) + { + if (attrCurrentPositionTilt.IsNull()) + { + VerifyOrReturn(CheckValueNull("targetPositionTiltPercent100ths", targetPositionTiltPercent100ths)); + } + else + { + VerifyOrReturn(CheckValueNonNull("targetPositionTiltPercent100ths", targetPositionTiltPercent100ths)); + VerifyOrReturn(CheckValue("targetPositionTiltPercent100ths.Value()", targetPositionTiltPercent100ths.Value(), + attrCurrentPositionTilt.Value())); + } + + NextTest(); + } }; class TV_TargetNavigatorCluster : public TestCommand diff --git a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h index 89b3b75b5fb7ea..357c018ce8418d 100644 --- a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h +++ b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h @@ -1491,6 +1491,9 @@ (EmberAfGenericClusterFunction) MatterDoorLockClusterServerAttributeChangedCallback, \ (EmberAfGenericClusterFunction) MatterDoorLockClusterServerPreAttributeChangedCallback, \ }; \ + const EmberAfGenericClusterFunction chipFuncArrayWindowCoveringServer[] = { \ + (EmberAfGenericClusterFunction) MatterWindowCoveringClusterServerAttributeChangedCallback, \ + }; \ const EmberAfGenericClusterFunction chipFuncArrayThermostatServer[] = { \ (EmberAfGenericClusterFunction) emberAfThermostatClusterServerInitCallback, \ }; \ @@ -2102,8 +2105,8 @@ .attributes = ZAP_ATTRIBUTE_INDEX(275), \ .attributeCount = 19, \ .clusterSize = 31, \ - .mask = ZAP_CLUSTER_MASK(SERVER), \ - .functions = NULL, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ + .functions = chipFuncArrayWindowCoveringServer, \ .clientGeneratedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 110 ) ,\ .serverGeneratedCommandList = nullptr ,\ },\ diff --git a/zzz_generated/window-app/zap-generated/endpoint_config.h b/zzz_generated/window-app/zap-generated/endpoint_config.h index 6191c2e4027516..2d2840193f8f7a 100644 --- a/zzz_generated/window-app/zap-generated/endpoint_config.h +++ b/zzz_generated/window-app/zap-generated/endpoint_config.h @@ -275,12 +275,12 @@ /* Endpoint: 1, Cluster: Window Covering (server), big-endian */ \ \ /* 383 - FeatureMap, */ \ - 0x00, 0x00, 0x00, 0x01, \ + 0x00, 0x00, 0x00, 0x17, \ \ /* Endpoint: 2, Cluster: Window Covering (server), big-endian */ \ \ /* 387 - FeatureMap, */ \ - 0x00, 0x00, 0x00, 0x01, \ + 0x00, 0x00, 0x00, 0x17, \ } #else // !BIGENDIAN_CPU @@ -533,12 +533,12 @@ /* Endpoint: 1, Cluster: Window Covering (server), little-endian */ \ \ /* 383 - FeatureMap, */ \ - 0x01, 0x00, 0x00, 0x00, \ + 0x17, 0x00, 0x00, 0x00, \ \ /* Endpoint: 2, Cluster: Window Covering (server), little-endian */ \ \ /* 387 - FeatureMap, */ \ - 0x01, 0x00, 0x00, 0x00, \ + 0x17, 0x00, 0x00, 0x00, \ } #endif // BIGENDIAN_CPU