From 834888601dc6d2d7a7224c197f1b812176c82d78 Mon Sep 17 00:00:00 2001 From: Jonathan Megevand Date: Wed, 25 Aug 2021 18:29:50 +0200 Subject: [PATCH] WC: Add missing test dependancies --- .../all-clusters-common/all-clusters-app.zap | 2 +- .../certification/Test_TC_WNCV_1_1.yaml | 6 +- .../Framework/CHIPTests/CHIPClustersTests.m | 36 +++++ .../zap-generated/endpoint_config.h | 4 +- .../chip-tool/zap-generated/test/Commands.h | 134 +++++++++++++++++- 5 files changed, 175 insertions(+), 7 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index ed99ecfce9dd95..aafa198cb64ed1 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -9547,7 +9547,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0001", + "defaultValue": "0", "reportable": 0, "minInterval": 0, "maxInterval": 65344, diff --git a/src/app/tests/suites/certification/Test_TC_WNCV_1_1.yaml b/src/app/tests/suites/certification/Test_TC_WNCV_1_1.yaml index 84a4dbe561c660..8119fd6ab8f7ea 100644 --- a/src/app/tests/suites/certification/Test_TC_WNCV_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_WNCV_1_1.yaml @@ -46,14 +46,14 @@ tests: command: "readAttribute" attribute: "FeatureMap" response: - value: 1 + value: 0 - label: "write the default value to optional global attribute: FeatureMap" disabled: true command: "writeAttribute" attribute: "FeatureMap" arguments: - value: 0 + value: 5 response: error: 1 @@ -61,4 +61,4 @@ tests: command: "readAttribute" attribute: "FeatureMap" response: - value: 1 + value: 0 diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index fdd358c5fa216a..b9109d828218a7 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -4807,6 +4807,42 @@ - (void)testSendClusterTest_TC_WNCV_1_1_000001_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterTest_TC_WNCV_1_1_000002_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"read the global attribute: FeatureMap"]; + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPWindowCovering * cluster = [[CHIPWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeFeatureMapWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"read the global attribute: FeatureMap Error: %@", err); + + XCTAssertEqual(err.code, 0); + XCTAssertEqual([values[@"value"] unsignedLongValue], 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_WNCV_1_1_000003_ReadAttribute +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"reads back global attribute: FeatureMap"]; + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPWindowCovering * cluster = [[CHIPWindowCovering alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeFeatureMapWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"reads back global attribute: FeatureMap Error: %@", err); + + XCTAssertEqual(err.code, 0); + XCTAssertEqual([values[@"value"] unsignedLongValue], 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} - (void)testSendClusterTest_TC_WNCV_2_1_000000_ReadAttribute { diff --git a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h index ed38bb173badac..f70bce2ea9e965 100644 --- a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h +++ b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h @@ -625,7 +625,7 @@ /* Endpoint: 1, Cluster: Window Covering (server), big-endian */ \ \ /* 5854 - FeatureMap, */ \ - 0x00, 0x00, 0x00, 0x01, \ + 0x00, 0x00, 0x00, 0x00, \ \ /* Endpoint: 1, Cluster: Thermostat (server), big-endian */ \ \ @@ -1594,7 +1594,7 @@ /* Endpoint: 1, Cluster: Window Covering (server), little-endian */ \ \ /* 5854 - FeatureMap, */ \ - 0x00, 0x00, 0x00, 0x01, \ + 0x00, 0x00, 0x00, 0x00, \ \ /* Endpoint: 1, Cluster: Thermostat (server), little-endian */ \ \ diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index c5db950b963be9..f1d275b2ec0470 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -17947,6 +17947,12 @@ class Test_TC_WNCV_1_1 : public TestCommand case 1: err = TestSendClusterWindowCoveringCommandReadAttribute_1(); break; + case 2: + err = TestSendClusterWindowCoveringCommandReadAttribute_2(); + break; + case 3: + err = TestSendClusterWindowCoveringCommandReadAttribute_3(); + break; } if (CHIP_NO_ERROR != err) @@ -17958,7 +17964,7 @@ class Test_TC_WNCV_1_1 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; + const uint16_t mTestCount = 4; // // Tests methods @@ -18089,6 +18095,132 @@ class Test_TC_WNCV_1_1 : public TestCommand runner->NextTest(); } + + // Test read the global attribute: FeatureMap + using SuccessCallback_2 = void (*)(void * context, uint32_t featureMap); + chip::Callback::Callback mOnSuccessCallback_2{ + OnTestSendClusterWindowCoveringCommandReadAttribute_2_SuccessResponse, this + }; + chip::Callback::Callback mOnFailureCallback_2{ + OnTestSendClusterWindowCoveringCommandReadAttribute_2_FailureResponse, this + }; + bool mIsFailureExpected_2 = 0; + + CHIP_ERROR TestSendClusterWindowCoveringCommandReadAttribute_2() + { + ChipLogProgress(chipTool, "Window Covering - read the global attribute: FeatureMap: Sending command..."); + + chip::Controller::WindowCoveringCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeFeatureMap(mOnSuccessCallback_2.Cancel(), mOnFailureCallback_2.Cancel()); + + return err; + } + + static void OnTestSendClusterWindowCoveringCommandReadAttribute_2_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Window Covering - read the global attribute: FeatureMap: Failure Response"); + + Test_TC_WNCV_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_2 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterWindowCoveringCommandReadAttribute_2_SuccessResponse(void * context, uint32_t featureMap) + { + ChipLogProgress(chipTool, "Window Covering - read the global attribute: FeatureMap: Success Response"); + + Test_TC_WNCV_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_2 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (featureMap != 0UL) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test reads back global attribute: FeatureMap + using SuccessCallback_3 = void (*)(void * context, uint32_t featureMap); + chip::Callback::Callback mOnSuccessCallback_3{ + OnTestSendClusterWindowCoveringCommandReadAttribute_3_SuccessResponse, this + }; + chip::Callback::Callback mOnFailureCallback_3{ + OnTestSendClusterWindowCoveringCommandReadAttribute_3_FailureResponse, this + }; + bool mIsFailureExpected_3 = 0; + + CHIP_ERROR TestSendClusterWindowCoveringCommandReadAttribute_3() + { + ChipLogProgress(chipTool, "Window Covering - reads back global attribute: FeatureMap: Sending command..."); + + chip::Controller::WindowCoveringCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeFeatureMap(mOnSuccessCallback_3.Cancel(), mOnFailureCallback_3.Cancel()); + + return err; + } + + static void OnTestSendClusterWindowCoveringCommandReadAttribute_3_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Window Covering - reads back global attribute: FeatureMap: Failure Response"); + + Test_TC_WNCV_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_3 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterWindowCoveringCommandReadAttribute_3_SuccessResponse(void * context, uint32_t featureMap) + { + ChipLogProgress(chipTool, "Window Covering - reads back global attribute: FeatureMap: Success Response"); + + Test_TC_WNCV_1_1 * runner = reinterpret_cast(context); + + if (runner->mIsFailureExpected_3 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (featureMap != 0UL) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } }; class Test_TC_WNCV_2_1 : public TestCommand