diff --git a/src/app/tests/suites/certification/Test_TC_WNCV_4_3.yaml b/src/app/tests/suites/certification/Test_TC_WNCV_4_3.yaml index b3bb217a7d9b76..86658e0313495d 100644 --- a/src/app/tests/suites/certification/Test_TC_WNCV_4_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_WNCV_4_3.yaml @@ -47,20 +47,19 @@ tests: maxValue: 10000 - label: - "1b: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT" + "1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from + DUT + assert CurrentPositionLiftPercent100ths/100 equals + CurrentPositionLiftPercentage" + disabled: true command: "readAttribute" attribute: "CurrentPositionLiftPercentage" PICS: WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE response: - saveAs: attrCurrentPositionLiftPercentage + value: attrCurrentPositionLiftPercent100ths / 100 constraints: minValue: 0 maxValue: 100 - ##- label: "1c: If (PA_LF & LF) TH assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage" - ## PICS: WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE - # TODO [TC_WNCV_4_3] WindowCovering Fix this arithmetic operation issue #15190 - ######## Command BadParams 1 ####### ### Step 2x -> Verify the GoToLiftPercentage with a BadParam diff --git a/src/app/zap-templates/common/ClusterTestGeneration.js b/src/app/zap-templates/common/ClusterTestGeneration.js index f40d1f479b3252..5e690ee12701e3 100644 --- a/src/app/zap-templates/common/ClusterTestGeneration.js +++ b/src/app/zap-templates/common/ClusterTestGeneration.js @@ -639,6 +639,12 @@ function chip_tests_variables_get_type(name, options) return variable.type; } +function chip_tests_variables_is_nullable(name, options) +{ + const variable = getVariableOrThrow(this, 'tests', name); + return variable.isNullable; +} + function chip_tests_config(options) { return templateUtil.collectBlocks(this.variables.config, options, this); @@ -898,6 +904,7 @@ exports.chip_tests_config_get_type = chip_tests_config_get_type; exports.chip_tests_variables = chip_tests_variables; exports.chip_tests_variables_has = chip_tests_variables_has; exports.chip_tests_variables_get_type = chip_tests_variables_get_type; +exports.chip_tests_variables_is_nullable = chip_tests_variables_is_nullable; exports.isTestOnlyCluster = isTestOnlyCluster; exports.isLiteralNull = isLiteralNull; exports.octetStringEscapedForCLiteral = octetStringEscapedForCLiteral; diff --git a/src/app/zap-templates/common/variables/Variables.js b/src/app/zap-templates/common/variables/Variables.js index 978661cebc59cc..31a9eb27caacf2 100644 --- a/src/app/zap-templates/common/variables/Variables.js +++ b/src/app/zap-templates/common/variables/Variables.js @@ -27,10 +27,10 @@ const templateUtil = require(zapPath + 'generator/template-util.js') const { getCommands, getAttributes } = require('../simulated-clusters/SimulatedClusters.js'); const knownVariables = { - 'nodeId' : { type : 'NODE_ID', defaultValue : 0x12345 }, - 'endpoint' : { type : 'ENDPOINT_NO', defaultValue : '' }, - 'cluster' : { type : 'CHAR_STRING', defaultValue : '' }, - 'timeout' : { type : 'INT16U', defaultValue : "kTimeoutInSeconds" }, + 'nodeId' : { type : 'NODE_ID', defaultValue : 0x12345, isNullable : false }, + 'endpoint' : { type : 'ENDPOINT_NO', defaultValue : '', isNullable : false }, + 'cluster' : { type : 'CHAR_STRING', defaultValue : '', isNullable : false }, + 'timeout' : { type : 'INT16U', defaultValue : "kTimeoutInSeconds", isNullable : false }, }; function throwError(test, errorStr) @@ -57,13 +57,13 @@ async function getCommandInformationsFor(context, test, argumentName) { const command = await getItems(test, getCommands(context, test.cluster), test.command); const argument = command.response.arguments.find(item => item.name.toLowerCase() == argumentName.toLowerCase()); - return { type : argument.type, chipType : argument.chipType }; + return { type : argument.type, chipType : argument.chipType, isNullable : argument.isNullable }; } async function getAttributeInformationsFor(context, test, attributeName) { const attribute = await getItems(test, getAttributes(context, test.cluster), attributeName); - return { type : attribute.type, chipType : attribute.chipType }; + return { type : attribute.type, chipType : attribute.chipType, isNullable : attribute.isNullable }; } async function extractVariablesFromConfig(context, suite) diff --git a/src/app/zap-templates/templates/app/helper.js b/src/app/zap-templates/templates/app/helper.js index 6948cc588aa5c4..8b7c02b11b5089 100644 --- a/src/app/zap-templates/templates/app/helper.js +++ b/src/app/zap-templates/templates/app/helper.js @@ -28,6 +28,7 @@ const dbEnum = require(zapPath + '../src-shared/db-enum.js') const StringHelper = require('../../common/StringHelper.js'); const ChipTypesHelper = require('../../common/ChipTypesHelper.js'); +const TestHelper = require('../../common/ClusterTestGeneration.js'); zclHelper['isEvent'] = function(db, event_name, packageId) { return queryEvents @@ -400,6 +401,20 @@ async function asTypedExpression(value, type) return asTypedLiteral.call(this, value, type); } + value = tokens + .map(token => { + if (!TestHelper.chip_tests_variables_has.call(this, token)) { + return token; + } + + if (!TestHelper.chip_tests_variables_is_nullable.call(this, token)) { + return token; + } + + return `${token}.Value()`; + }) + .join(' '); + const resultType = await asNativeType.call(this, type); return `static_cast<${resultType}>(${value})`; } diff --git a/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h b/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h index b33933c3a5c8a1..e7b955f9eb2d54 100644 --- a/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h @@ -59917,36 +59917,28 @@ class Test_TC_WNCV_4_3 : public TestCommandBridge { err = Test1aIfPaLfLfThReadsCurrentPositionLiftPercent100thsFromDut_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : 1b: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT\n"); - if (ShouldSkip("WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE")) { + ChipLogProgress(chipTool, " ***** Test Step 2 : 2b: TH sends GoToLiftPercentage command with BadParam to DUT\n"); + if (ShouldSkip("WNCV_LF && WNCV_PA_LF || WNCV_LF && CR_GOTOLIFTPERCENTAGE")) { NextTest(); return; } - err = Test1bIfPaLfLfThReadsCurrentPositionLiftPercentageFromDut_2(); + err = Test2bThSendsGoToLiftPercentageCommandWithBadParamToDut_2(); break; case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : 2b: TH sends GoToLiftPercentage command with BadParam to DUT\n"); + ChipLogProgress(chipTool, " ***** Test Step 3 : 3a: TH sends GoToLiftPercentage command with 10001 to DUT\n"); if (ShouldSkip("WNCV_LF && WNCV_PA_LF || WNCV_LF && CR_GOTOLIFTPERCENTAGE")) { NextTest(); return; } - err = Test2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3(); + err = Test3aThSendsGoToLiftPercentageCommandWith10001ToDut_3(); break; case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : 3a: TH sends GoToLiftPercentage command with 10001 to DUT\n"); + ChipLogProgress(chipTool, " ***** Test Step 4 : 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT\n"); if (ShouldSkip("WNCV_LF && WNCV_PA_LF || WNCV_LF && CR_GOTOLIFTPERCENTAGE")) { NextTest(); return; } - err = Test3aThSendsGoToLiftPercentageCommandWith10001ToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT\n"); - if (ShouldSkip("WNCV_LF && WNCV_PA_LF || WNCV_LF && CR_GOTOLIFTPERCENTAGE")) { - NextTest(); - return; - } - err = Test4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5(); + err = Test4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_4(); break; } @@ -59966,7 +59958,7 @@ class Test_TC_WNCV_4_3 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; case 3: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); @@ -59974,9 +59966,6 @@ class Test_TC_WNCV_4_3 : public TestCommandBridge { case 4: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; } // Go on to the next test. @@ -59990,7 +59979,7 @@ class Test_TC_WNCV_4_3 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; + const uint16_t mTestCount = 5; chip::Optional mNodeId; chip::Optional mCluster; @@ -60035,40 +60024,8 @@ class Test_TC_WNCV_4_3 : public TestCommandBridge { return CHIP_NO_ERROR; } - NSNumber * _Nullable attrCurrentPositionLiftPercentage; - - CHIP_ERROR Test1bIfPaLfLfThReadsCurrentPositionLiftPercentageFromDut_2() - { - SetIdentity("alpha"); - CHIPDevice * device = GetConnectedDevice(); - CHIPTestWindowCovering * cluster = [[CHIPTestWindowCovering alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster - readAttributeCurrentPositionLiftPercentageWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"1b: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err, 0)); - - if (value != nil) { - VerifyOrReturn( - CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0)); - } - if (value != nil) { - VerifyOrReturn( - CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100)); - } - { - attrCurrentPositionLiftPercentage = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - CHIP_ERROR Test2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3() + CHIP_ERROR Test2bThSendsGoToLiftPercentageCommandWithBadParamToDut_2() { SetIdentity("alpha"); CHIPDevice * device = GetConnectedDevice(); @@ -60089,7 +60046,7 @@ class Test_TC_WNCV_4_3 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR Test3aThSendsGoToLiftPercentageCommandWith10001ToDut_4() + CHIP_ERROR Test3aThSendsGoToLiftPercentageCommandWith10001ToDut_3() { SetIdentity("alpha"); CHIPDevice * device = GetConnectedDevice(); @@ -60110,7 +60067,7 @@ class Test_TC_WNCV_4_3 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR Test4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5() + CHIP_ERROR Test4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_4() { SetIdentity("alpha"); CHIPDevice * device = GetConnectedDevice(); diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 2ac682e1afed01..7fe7b35bca2159 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -31528,7 +31528,7 @@ class Test_TC_WNCV_4_2Suite : public TestCommand class Test_TC_WNCV_4_3Suite : public TestCommand { public: - Test_TC_WNCV_4_3Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_WNCV_4_3", 6, credsIssuerConfig) + Test_TC_WNCV_4_3Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_WNCV_4_3", 5, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -31550,7 +31550,6 @@ class Test_TC_WNCV_4_3Suite : public TestCommand chip::Optional mTimeout; chip::app::DataModel::Nullable attrCurrentPositionLiftPercent100ths; - chip::app::DataModel::Nullable attrCurrentPositionLiftPercentage; chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } @@ -31579,14 +31578,7 @@ class Test_TC_WNCV_4_3Suite : public TestCommand } break; case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::DataModel::Nullable value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckConstraintMinValue("value", value, 0)); - VerifyOrReturn(CheckConstraintMaxValue("value", value, 100)); - attrCurrentPositionLiftPercentage = value; - } + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; case 3: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); @@ -31594,9 +31586,6 @@ class Test_TC_WNCV_4_3Suite : public TestCommand case 4: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); } @@ -31624,14 +31613,7 @@ class Test_TC_WNCV_4_3Suite : public TestCommand WindowCovering::Attributes::CurrentPositionLiftPercent100ths::Id); } case 2: { - LogStep(2, "1b: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT"); - VerifyOrdo(!ShouldSkip("WNCV_LF && WNCV_PA_LF && A_CURRENTPOSITIONLIFTPERCENTAGE"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), WindowCovering::Id, - WindowCovering::Attributes::CurrentPositionLiftPercentage::Id); - } - case 3: { - LogStep(3, "2b: TH sends GoToLiftPercentage command with BadParam to DUT"); + LogStep(2, "2b: TH sends GoToLiftPercentage command with BadParam to DUT"); VerifyOrdo(!ShouldSkip("WNCV_LF && WNCV_PA_LF || WNCV_LF && CR_GOTOLIFTPERCENTAGE"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); chip::app::Clusters::WindowCovering::Commands::GoToLiftPercentage::Type value; @@ -31641,8 +31623,8 @@ class Test_TC_WNCV_4_3Suite : public TestCommand return SendCommand(kIdentityAlpha, GetEndpoint(1), WindowCovering::Id, WindowCovering::Commands::GoToLiftPercentage::Id, value); } - case 4: { - LogStep(4, "3a: TH sends GoToLiftPercentage command with 10001 to DUT"); + case 3: { + LogStep(3, "3a: TH sends GoToLiftPercentage command with 10001 to DUT"); VerifyOrdo(!ShouldSkip("WNCV_LF && WNCV_PA_LF || WNCV_LF && CR_GOTOLIFTPERCENTAGE"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); chip::app::Clusters::WindowCovering::Commands::GoToLiftPercentage::Type value; @@ -31652,8 +31634,8 @@ class Test_TC_WNCV_4_3Suite : public TestCommand return SendCommand(kIdentityAlpha, GetEndpoint(1), WindowCovering::Id, WindowCovering::Commands::GoToLiftPercentage::Id, value); } - case 5: { - LogStep(5, "4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT"); + case 4: { + LogStep(4, "4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT"); VerifyOrdo(!ShouldSkip("WNCV_LF && WNCV_PA_LF || WNCV_LF && CR_GOTOLIFTPERCENTAGE"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); chip::app::Clusters::WindowCovering::Commands::GoToLiftPercentage::Type value;